The native runtime for three.js: three.js, down to the metal. 45× smaller than Electron, on a Sony PS3, and path-traced at 60 fps on ray-tracing GPUs.
Rust electron-alternativegame-engineglobal-illuminationgraphicsjavascript-runtimemetalpath-tracingray-tracingreal-time-renderingrenderingrustthreejstypescriptvoxelvulkanwebgpuwgpu
Scene: Texture.needsUpdate = true bumps Texture.version, as three.js does (#136)
Kevin Rajan625088092c54
diff --git a/packages/scene/src/core.ts b/packages/scene/src/core.tsindex 6b7242d..33ae4a8 100644--- a/packages/scene/src/core.ts+++ b/packages/scene/src/core.ts@@ -1013,8 +1013,17 @@ export class Texture {wrap: "repeat" | "clamp" = "repeat";/** Raw bytes for generated textures (PNG); external textures are fetched from `uri`. */data?: Uint8Array;+ /** Number of times the texture was marked for upload, as in three.js. */+ version = 0;+ private dirty = false;/** Set after changing a texture the engine already has (new data / uri / repeat). */- needsUpdate = false;+ get needsUpdate(): boolean {+ return this.dirty;+ }+ set needsUpdate(value: boolean) {+ if (value === true) this.version++;+ this.dirty = value;+ }constructor(uri: string, colorSpace: "srgb" | "linear" = "srgb") {this.uri = uri;this.colorSpace = colorSpace;diff --git a/packages/scene/test/three-compat-texture.test.ts b/packages/scene/test/three-compat-texture.test.tsnew file mode 100644index 0000000..50d1720--- /dev/null+++ b/packages/scene/test/three-compat-texture.test.ts@@ -0,0 +1,18 @@+// Texture.needsUpdate version parity with three.js r187.+import { test } from "node:test";+import assert from "node:assert/strict";+import * as THREE from "../src/index.ts";++test("Texture.needsUpdate advances version on every true assignment", () => {+ const texture = new THREE.Texture("texture.png");+ assert.equal(texture.version, 0, "new textures start at version zero");++ texture.needsUpdate = false;+ assert.equal(texture.version, 0, "false does not change version");+ texture.needsUpdate = true;+ assert.equal(texture.version, 1, "first true increments once");+ texture.needsUpdate = true;+ assert.equal(texture.version, 2, "repeated true increments again");+ texture.needsUpdate = false;+ assert.equal(texture.version, 2, "resetting the dirty flag does not increment");+});