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: BufferAttribute.copyAt, as three.js has it (#129)
Kevin Rajan505f3fd0f9fe
diff --git a/packages/scene/src/geometry.ts b/packages/scene/src/geometry.tsindex 17e7984..7ace43c 100644--- a/packages/scene/src/geometry.ts+++ b/packages/scene/src/geometry.ts@@ -101,6 +101,15 @@ export class BufferAttribute {this.array.set(values, offset);return this;}+ /** Copies one item's stored components from another attribute, without normalization. */+ copyAt(index1: number, attribute: BufferAttribute, index2: number): this {+ const dst = index1 * this.itemSize;+ const src = index2 * attribute.itemSize;+ for (let i = 0; i < this.itemSize; i++) {+ this.array[dst + i] = attribute.array[src + i];+ }+ return this;+ }copyArray(values: ArrayLike<number>): this {return this.set(values);}diff --git a/packages/scene/test/three-compat-attribute.test.ts b/packages/scene/test/three-compat-attribute.test.tsnew file mode 100644index 0000000..0d06661--- /dev/null+++ b/packages/scene/test/three-compat-attribute.test.ts@@ -0,0 +1,14 @@+// BufferAttribute tuple-copy parity with three.js r187.+import { test } from "node:test";+import assert from "node:assert/strict";+import * as THREE from "../src/index.ts";++test("BufferAttribute.copyAt copies raw tuple values at item offsets as three.js does", () => {+ const source = new THREE.BufferAttribute(new Uint8Array([10, 20, 30, 40, 50, 60]), 3, true);+ const destination = new THREE.BufferAttribute(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9]), 3, true);+ assert.equal(destination.copyAt(1, source, 0), destination, "copyAt is chainable");+ assert.deepEqual([...destination.array], [1, 2, 3, 10, 20, 30, 7, 8, 9], "destination index uses itemSize");+ assert.equal(destination.copyAt(2, source, 1), destination);+ assert.deepEqual([...destination.array], [1, 2, 3, 10, 20, 30, 40, 50, 60], "source index uses itemSize");+ assert.equal(destination.version, 0, "copyAt does not itself mark an attribute for GPU update");+});