Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RenderObject: Fix geometry key for morph targets. #1504

Merged
merged 10 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -13335,6 +13335,28 @@ index 45619da3..97df59b3 100644
switch (event.keyCode) {
case 79 /*O*/:
activeCamera = cameraOrtho;
diff --git a/examples-testing/examples/webgpu_camera_array.ts b/examples-testing/examples/webgpu_camera_array.ts
index 2e8218be..92051ebc 100644
--- a/examples-testing/examples/webgpu_camera_array.ts
+++ b/examples-testing/examples/webgpu_camera_array.ts
@@ -1,6 +1,6 @@
-import * as THREE from 'three';
+import * as THREE from 'three/webgpu';

-let camera, scene, renderer;
+let camera: THREE.ArrayCamera, scene: THREE.Scene, renderer: THREE.WebGPURenderer;
let mesh;
const AMOUNT = 6;

@@ -87,7 +87,7 @@ function onWindowResize() {
for (let x = 0; x < AMOUNT; x++) {
const subcamera = camera.cameras[AMOUNT * y + x];

- subcamera.viewport.set(Math.floor(x * WIDTH), Math.floor(y * HEIGHT), Math.ceil(WIDTH), Math.ceil(HEIGHT));
+ subcamera.viewport!.set(Math.floor(x * WIDTH), Math.floor(y * HEIGHT), Math.ceil(WIDTH), Math.ceil(HEIGHT));

subcamera.aspect = ASPECT_RATIO;
subcamera.updateProjectionMatrix();
diff --git a/examples-testing/examples/webgpu_camera_logarithmicdepthbuffer.ts b/examples-testing/examples/webgpu_camera_logarithmicdepthbuffer.ts
index 15527632..58f5cc14 100644
--- a/examples-testing/examples/webgpu_camera_logarithmicdepthbuffer.ts
Expand Down Expand Up @@ -15894,7 +15916,7 @@ index 6e69c3be..2cdd4ba7 100644
mouse.y = e.offsetY / window.innerHeight;
}
diff --git a/examples-testing/examples/webgpu_occlusion.ts b/examples-testing/examples/webgpu_occlusion.ts
index 85dbc6f0..b641b745 100644
index d9eb32a2..02b0c1d9 100644
--- a/examples-testing/examples/webgpu_occlusion.ts
+++ b/examples-testing/examples/webgpu_occlusion.ts
@@ -1,12 +1,18 @@
Expand Down
59 changes: 30 additions & 29 deletions src-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ index d3ab54f8..1fdb5cf0 100644

addMethodChaining('toAttribute', bufferNode => bufferAttribute(bufferNode.value));
diff --git a/src-testing/src/nodes/accessors/TextureNode.ts b/src-testing/src/nodes/accessors/TextureNode.ts
index 4e41bb4f..480397d1 100644
index d6d8b80a..0603c8c2 100644
--- a/src-testing/src/nodes/accessors/TextureNode.ts
+++ b/src-testing/src/nodes/accessors/TextureNode.ts
@@ -4,10 +4,15 @@ import { textureSize } from './TextureSizeNode.js';
Expand Down Expand Up @@ -497,16 +497,16 @@ index 4e41bb4f..480397d1 100644
this.sampler = value;

return this;
@@ -468,7 +494,7 @@ class TextureNode extends UniformNode {

// @TODO: Move to TSL

@@ -475,7 +501,7 @@ class TextureNode extends UniformNode {
* @param {Node} uvNode - The uv node.
* @return {TextureNode} A texture node representing the texture sample.
*/
- uv(uvNode) {
+ uv(uvNode: ShaderNodeObject<Node> | null) {
// @deprecated, r172

console.warn('THREE.TextureNode: .uv() has been renamed. Use .sample() instead.');
@@ -496,7 +522,7 @@ class TextureNode extends UniformNode {
@@ -503,7 +529,7 @@ class TextureNode extends UniformNode {
* @param {Node<float>} amountNode - How blurred the texture should be.
* @return {TextureNode} A texture node representing the texture sample.
*/
Expand All @@ -515,7 +515,7 @@ index 4e41bb4f..480397d1 100644
const textureNode = this.clone();
textureNode.biasNode = nodeObject(amountNode).mul(maxMipLevel(textureNode));
textureNode.referenceNode = this.getSelf();
@@ -510,7 +536,7 @@ class TextureNode extends UniformNode {
@@ -517,7 +543,7 @@ class TextureNode extends UniformNode {
* @param {Node<int>} levelNode - The mip level to sample.
* @return {TextureNode} A texture node representing the texture sample.
*/
Expand Down Expand Up @@ -1271,7 +1271,7 @@ index b1a5c99b..df827f78 100644
* This flag can be used for type testing.
*
diff --git a/src-testing/src/nodes/core/NodeBuilder.ts b/src-testing/src/nodes/core/NodeBuilder.ts
index 0736b400..345d0f7f 100644
index 30598127..e9ddf0f1 100644
--- a/src-testing/src/nodes/core/NodeBuilder.ts
+++ b/src-testing/src/nodes/core/NodeBuilder.ts
@@ -9,7 +9,7 @@ import StructTypeNode from './StructTypeNode.js';
Expand Down Expand Up @@ -2736,7 +2736,7 @@ index 8a291b92..39c864a4 100644

/**
diff --git a/src-testing/src/nodes/core/StackNode.ts b/src-testing/src/nodes/core/StackNode.ts
index eb1dadc7..36ade03e 100644
index 8cd4175a..68f7a383 100644
--- a/src-testing/src/nodes/core/StackNode.ts
+++ b/src-testing/src/nodes/core/StackNode.ts
@@ -1,6 +1,7 @@
Expand Down Expand Up @@ -3122,7 +3122,7 @@ index 1aa67531..25a4bd72 100644
this.value.lightingModel = this.lightingModel || builder.context.lightingModel;

diff --git a/src-testing/src/nodes/tsl/TSLCore.ts b/src-testing/src/nodes/tsl/TSLCore.ts
index 4ac059f0..fcb1c9fd 100644
index 227dc9db..549cbbb7 100644
--- a/src-testing/src/nodes/tsl/TSLCore.ts
+++ b/src-testing/src/nodes/tsl/TSLCore.ts
@@ -7,11 +7,40 @@ import SetNode from '../utils/SetNode.js';
Expand All @@ -3131,7 +3131,7 @@ index 4ac059f0..fcb1c9fd 100644
import { getValueFromType, getValueType } from '../core/NodeUtils.js';
+import NodeBuilder from '../core/NodeBuilder.js';

//
/** @module TSLCore **/

let currentStack = null;

Expand Down Expand Up @@ -3341,7 +3341,7 @@ index 4ac059f0..fcb1c9fd 100644
const { shaderNode, inputNodes } = this;

const properties = builder.getNodeProperties(shaderNode);
@@ -272,7 +438,15 @@ class ShaderCallNodeInternal extends Node {
@@ -273,7 +439,15 @@ class ShaderCallNodeInternal extends Node {
}
}

Expand All @@ -3357,7 +3357,7 @@ index 4ac059f0..fcb1c9fd 100644
constructor(jsFunc, nodeType) {
super(nodeType);

@@ -284,7 +458,7 @@ class ShaderNodeInternal extends Node {
@@ -285,7 +459,7 @@ class ShaderNodeInternal extends Node {
this.once = false;
}

Expand All @@ -3366,7 +3366,7 @@ index 4ac059f0..fcb1c9fd 100644
this.layout = layout;

return this;
@@ -301,6 +475,8 @@ class ShaderNodeInternal extends Node {
@@ -302,6 +476,8 @@ class ShaderNodeInternal extends Node {
}
}

Expand All @@ -3375,7 +3375,7 @@ index 4ac059f0..fcb1c9fd 100644
const bools = [false, true];
const uints = [0, 1, 2, 3];
const ints = [-1, -2];
@@ -394,10 +570,27 @@ export function ShaderNode(jsFunc, nodeType) {
@@ -395,10 +571,27 @@ export function ShaderNode(jsFunc, nodeType) {
return new Proxy(new ShaderNodeInternal(jsFunc, nodeType), shaderNodeHandler);
}

Expand Down Expand Up @@ -5329,7 +5329,7 @@ index d6c72696..3ae4005b 100644

_chainKeys[0] = bundleGroup;
diff --git a/src-testing/src/renderers/common/RenderContext.ts b/src-testing/src/renderers/common/RenderContext.ts
index 3db4ccbe..9b0c7493 100644
index 17124b62..ed67c412 100644
--- a/src-testing/src/renderers/common/RenderContext.ts
+++ b/src-testing/src/renderers/common/RenderContext.ts
@@ -1,5 +1,9 @@
Expand Down Expand Up @@ -5728,7 +5728,7 @@ index d12ad583..ef6e14ec 100644
}

diff --git a/src-testing/src/renderers/common/RenderObject.ts b/src-testing/src/renderers/common/RenderObject.ts
index 449b8028..3f506673 100644
index d4cc350a..8d62b85b 100644
--- a/src-testing/src/renderers/common/RenderObject.ts
+++ b/src-testing/src/renderers/common/RenderObject.ts
@@ -1,8 +1,27 @@
Expand Down Expand Up @@ -5882,7 +5882,7 @@ index 449b8028..3f506673 100644

for (const nodeAttribute of nodeAttributes) {
const attribute =
@@ -681,7 +741,7 @@ class RenderObject {
@@ -693,7 +753,7 @@ class RenderObject {
dispose() {
this.material.removeEventListener('dispose', this.onMaterialDispose);

Expand Down Expand Up @@ -6050,7 +6050,7 @@ index 78ce62cb..e978810d 100644

/**
diff --git a/src-testing/src/renderers/common/Renderer.ts b/src-testing/src/renderers/common/Renderer.ts
index 5ed43e22..81c62bbf 100644
index a5ec1592..bfa81fd3 100644
--- a/src-testing/src/renderers/common/Renderer.ts
+++ b/src-testing/src/renderers/common/Renderer.ts
@@ -36,7 +36,34 @@ import {
Expand Down Expand Up @@ -7056,7 +7056,7 @@ index 5ed43e22..81c62bbf 100644
// process renderable objects

for (let i = 0, il = renderList.length; i < il; i++) {
@@ -2359,31 +2608,31 @@ class Renderer {
@@ -2359,18 +2608,18 @@ class Renderer {

const { object, geometry, material, group, clippingContext } = renderItem;

Expand All @@ -7079,6 +7079,7 @@ index 5ed43e22..81c62bbf 100644
viewportValue.copy(vp).multiplyScalar(this._pixelRatio).floor();
viewportValue.minDepth = minDepth;
viewportValue.maxDepth = maxDepth;
@@ -2378,13 +2627,13 @@ class Renderer {

this.backend.updateViewport(this._currentRenderContext);

Expand All @@ -7097,7 +7098,7 @@ index 5ed43e22..81c62bbf 100644
lightsNode,
clippingContext,
passId,
@@ -2391,13 +2640,13 @@ class Renderer {
@@ -2392,13 +2641,13 @@ class Renderer {
}
}
} else {
Expand All @@ -7116,7 +7117,7 @@ index 5ed43e22..81c62bbf 100644
lightsNode,
clippingContext,
passId,
@@ -2420,7 +2669,17 @@ class Renderer {
@@ -2421,7 +2670,17 @@ class Renderer {
* @param {ClippingContext} clippingContext - The clipping context.
* @param {String?} [passId=null] - An optional ID for identifying the pass.
*/
Expand All @@ -7135,7 +7136,7 @@ index 5ed43e22..81c62bbf 100644
let overridePositionNode;
let overrideColorNode;
let overrideDepthNode;
@@ -2507,14 +2766,23 @@ class Renderer {
@@ -2508,14 +2767,23 @@ class Renderer {
* @param {ClippingContext} clippingContext - The clipping context.
* @param {String?} [passId=null] - An optional ID for identifying the pass.
*/
Expand All @@ -7162,7 +7163,7 @@ index 5ed43e22..81c62bbf 100644
clippingContext,
passId,
);
@@ -2523,18 +2791,18 @@ class Renderer {
@@ -2524,18 +2792,18 @@ class Renderer {

//

Expand All @@ -7187,7 +7188,7 @@ index 5ed43e22..81c62bbf 100644

//

@@ -2548,7 +2816,7 @@ class Renderer {
@@ -2549,7 +2817,7 @@ class Renderer {

this.backend.draw(renderObject, this.info);

Expand All @@ -7196,7 +7197,7 @@ index 5ed43e22..81c62bbf 100644
}

/**
@@ -2565,14 +2833,23 @@ class Renderer {
@@ -2566,14 +2834,23 @@ class Renderer {
* @param {ClippingContext} clippingContext - The clipping context.
* @param {String?} [passId=null] - An optional ID for identifying the pass.
*/
Expand All @@ -7223,7 +7224,7 @@ index 5ed43e22..81c62bbf 100644
clippingContext,
passId,
);
@@ -2581,16 +2858,16 @@ class Renderer {
@@ -2582,16 +2859,16 @@ class Renderer {

//

Expand Down Expand Up @@ -8751,7 +8752,7 @@ index 51bd2e13..74f42846 100644
const monitor = renderObject.getMonitor();

diff --git a/src-testing/src/renderers/webgl-fallback/WebGLBackend.ts b/src-testing/src/renderers/webgl-fallback/WebGLBackend.ts
index 6dbffadb..eb121811 100644
index 6a453fd4..00ac75fb 100644
--- a/src-testing/src/renderers/webgl-fallback/WebGLBackend.ts
+++ b/src-testing/src/renderers/webgl-fallback/WebGLBackend.ts
@@ -13,6 +13,7 @@ import { WebGLBufferRenderer } from './WebGLBufferRenderer.js';
Expand Down Expand Up @@ -9213,7 +9214,7 @@ index bc7914ba..ffbf5e67 100644
const nodeData = this.getDataFromNode(node, shaderStage, this.globalCache);

diff --git a/src-testing/src/renderers/webgpu/WebGPUBackend.ts b/src-testing/src/renderers/webgpu/WebGPUBackend.ts
index bc8b4ef5..28495763 100644
index d17e3a4b..eaeb4232 100644
--- a/src-testing/src/renderers/webgpu/WebGPUBackend.ts
+++ b/src-testing/src/renderers/webgpu/WebGPUBackend.ts
@@ -1279,7 +1279,14 @@ class WebGPUBackend extends Backend {
Expand Down
2 changes: 1 addition & 1 deletion three.js
Submodule three.js updated 42 files
+34 −1 build/three.cjs
+31 −1 build/three.core.js
+1 −1 build/three.core.min.js
+4 −2 build/three.module.js
+1 −1 build/three.module.min.js
+4 −1 build/three.tsl.js
+1 −1 build/three.tsl.min.js
+383 −53 build/three.webgpu.js
+1 −1 build/three.webgpu.min.js
+383 −53 build/three.webgpu.nodes.js
+1 −1 build/three.webgpu.nodes.min.js
+3 −0 docs/api/en/core/BufferAttribute.html
+2 −6 docs/manual/en/introduction/Color-management.html
+1 −0 examples/files.json
+ examples/screenshots/webgpu_camera_array.jpg
+ examples/screenshots/webxr_vr_layers.jpg
+142 −0 examples/webgpu_camera_array.html
+1 −6 examples/webgpu_occlusion.html
+5 −2 examples/webxr_vr_layers.html
+2 −2 manual/zh/shadertoy.html
+4 −0 src/core/BufferAttribute.js
+9 −0 src/nodes/accessors/StorageBufferNode.js
+7 −0 src/nodes/accessors/TextureNode.js
+8 −2 src/nodes/accessors/UniformArrayNode.js
+7 −0 src/nodes/core/NodeBuilder.js
+14 −1 src/nodes/core/StackNode.js
+7 −0 src/nodes/core/VarNode.js
+28 −0 src/nodes/display/BlendModes.js
+9 −0 src/nodes/display/ScreenNode.js
+17 −0 src/nodes/fog/Fog.js
+8 −1 src/nodes/math/ConditionalNode.js
+5 −1 src/nodes/math/MathNode.js
+7 −1 src/nodes/math/OperatorNode.js
+9 −2 src/nodes/tsl/TSLCore.js
+8 −1 src/nodes/utils/LoopNode.js
+21 −0 src/nodes/utils/Timer.js
+1 −1 src/renderers/common/RenderContext.js
+20 −6 src/renderers/common/RenderObject.js
+1 −0 src/renderers/common/Renderer.js
+1 −1 src/renderers/webgl-fallback/WebGLBackend.js
+18 −21 src/renderers/webgpu/WebGPUBackend.js
+3 −1 src/renderers/webxr/WebXRManager.js
5 changes: 5 additions & 0 deletions types/three/src/core/BufferAttribute.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ export class BufferAttribute {
*/
constructor(array: TypedArray, itemSize: number, normalized?: boolean);

/**
* Unique number for this attribute instance.
*/
readonly id: number;

/**
* Optional name for this attribute instance.
* @defaultValue ''
Expand Down
2 changes: 1 addition & 1 deletion types/three/src/renderers/common/RenderContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ declare class RenderContext {
getCacheKey(): number;
}
/**
* Computes a cache key for the given render context. This cache
* Computes a cache key for the given render context. This key
* should identify the render target state so it is possible to
* configure the correct attachments in the respective backend.
*
Expand Down
Loading