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: BufferGeometry.copy and clone carry userData, as three.js does (#130)
Kevin Rajan20163c49f2ed
diff --git a/packages/scene/src/geometry.ts b/packages/scene/src/geometry.tsindex 7ace43c..5ac07b1 100644--- a/packages/scene/src/geometry.ts+++ b/packages/scene/src/geometry.ts@@ -351,6 +351,7 @@ export class BufferGeometry {this.groups = g.groups.map((x) => ({ ...x }));this.parameters = { ...g.parameters };this.name = g.name;+ this.userData = g.userData;this.boundingBox = g.boundingBox?.clone() ?? null;this.boundingSphere = g.boundingSphere?.clone() ?? null;return this;diff --git a/packages/scene/test/three-compat-geometry-ops.test.ts b/packages/scene/test/three-compat-geometry-ops.test.tsnew file mode 100644index 0000000..f4ce047--- /dev/null+++ b/packages/scene/test/three-compat-geometry-ops.test.ts@@ -0,0 +1,21 @@+// BufferGeometry metadata parity with three.js r187.+import { test } from "node:test";+import assert from "node:assert/strict";+import * as THREE from "../src/index.ts";++test("BufferGeometry.copy and clone retain source userData, as three.js r187 does", () => {+ const source = new THREE.BufferGeometry();+ source.userData = { label: "sample", settings: { visible: true } };+ const copied = new THREE.BufferGeometry();+ copied.userData = { stale: true };++ assert.equal(copied.copy(source), copied, "copy returns the receiver");+ const cloned = source.clone();+ assert.notStrictEqual(cloned, source, "clone creates a separate geometry");+ assert.strictEqual(copied.userData, source.userData, "copy shares source metadata");+ assert.strictEqual(cloned.userData, source.userData, "clone shares source metadata");++ source.userData.label = "updated";+ assert.equal(copied.userData.label, "updated", "copy observes source updates");+ assert.equal(cloned.userData.label, "updated", "clone observes source updates");+});