Skip to content
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
2 changes: 1 addition & 1 deletion examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -15263,7 +15263,7 @@ index 0500afd3..43926a20 100644
init();

diff --git a/examples-testing/examples/webgpu_lines_fat_raycasting.ts b/examples-testing/examples/webgpu_lines_fat_raycasting.ts
index 67269546..f39f2d74 100644
index 8ca983b7..ea062729 100644
--- a/examples-testing/examples/webgpu_lines_fat_raycasting.ts
+++ b/examples-testing/examples/webgpu_lines_fat_raycasting.ts
@@ -1,4 +1,4 @@
Expand Down
1 change: 1 addition & 0 deletions examples-testing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const exceptionList = [
'webgpu_compute_cloth',
'webgpu_compute_geometry',
'webgpu_compute_particles',
'webgpu_compute_particles_fluid',
'webgpu_compute_particles_rain',
'webgpu_compute_particles_snow',
'webgpu_compute_water',
Expand Down
57 changes: 31 additions & 26 deletions src-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2610,7 +2610,7 @@ index a161dada..ed07bd6d 100644
* This flag can be used for type testing.
*
diff --git a/src-testing/src/nodes/core/NodeUtils.ts b/src-testing/src/nodes/core/NodeUtils.ts
index 91b1d9ba..ca165e48 100644
index 4e2497aa..2832779f 100644
--- a/src-testing/src/nodes/core/NodeUtils.ts
+++ b/src-testing/src/nodes/core/NodeUtils.ts
@@ -5,13 +5,14 @@ import { Matrix4 } from '../../math/Matrix4.js';
Expand Down Expand Up @@ -2744,7 +2744,7 @@ index 91b1d9ba..ca165e48 100644
}
}
}
@@ -202,7 +224,7 @@ export function getLengthFromType(type) {
@@ -240,7 +262,7 @@ export function getByteBoundaryFromType(type) {
* @param {any} value - The value.
* @return {?string} The data type.
*/
Expand Down Expand Up @@ -2929,12 +2929,13 @@ index b06830b4..27e70330 100644
this.members = members;
this.output = false;
diff --git a/src-testing/src/nodes/core/StructTypeNode.ts b/src-testing/src/nodes/core/StructTypeNode.ts
index aee48070..1a10ed51 100644
index e824f513..d3a3dd78 100644
--- a/src-testing/src/nodes/core/StructTypeNode.ts
+++ b/src-testing/src/nodes/core/StructTypeNode.ts
@@ -1,5 +1,16 @@
@@ -1,6 +1,17 @@
import Node from './Node.js';
import { getLengthFromType } from './NodeUtils.js';
import { getByteBoundaryFromType, getMemoryLengthFromType } from './NodeUtils.js';
import { GPU_CHUNK_BYTES } from '../../renderers/common/Constants.js';
+import NodeBuilder from './NodeBuilder.js';
+
+export interface MembersLayout {
Expand All @@ -2949,7 +2950,7 @@ index aee48070..1a10ed51 100644

/**
* Generates a layout for struct members.
@@ -9,7 +20,7 @@ import { getLengthFromType } from './NodeUtils.js';
@@ -10,7 +21,7 @@ import { GPU_CHUNK_BYTES } from '../../renderers/common/Constants.js';
* @param {Object.<string, string|Object>} members - An object where keys are member names and values are either types (as strings) or objects with type and atomic properties.
* @returns {Array.<{name: string, type: string, atomic: boolean}>} An array of member layouts.
*/
Expand All @@ -2958,7 +2959,7 @@ index aee48070..1a10ed51 100644
return Object.entries(members).map(([name, value]) => {
if (typeof value === 'string') {
return { name, type: value, atomic: false };
@@ -32,13 +43,18 @@ class StructTypeNode extends Node {
@@ -33,13 +44,18 @@ class StructTypeNode extends Node {
return 'StructTypeNode';
}

Expand All @@ -2978,15 +2979,19 @@ index aee48070..1a10ed51 100644
super('struct');

/**
@@ -76,29 +92,29 @@ class StructTypeNode extends Node {
let length = 0;

@@ -79,8 +95,8 @@ class StructTypeNode extends Node {
for (const member of this.membersLayout) {
- length += getLengthFromType(member.type);
+ length += getLengthFromType(member.type)!;
}
const type = member.type;

- const itemSize = getMemoryLengthFromType(type) * Float32Array.BYTES_PER_ELEMENT;
- const boundary = getByteBoundaryFromType(type);
+ const itemSize = getMemoryLengthFromType(type)! * Float32Array.BYTES_PER_ELEMENT;
+ const boundary = getByteBoundaryFromType(type)!;

return length;
const chunkOffset = offset % GPU_CHUNK_BYTES; // offset in the current chunk
const chunkPadding = chunkOffset % boundary; // required padding to match boundary
@@ -100,23 +116,23 @@ class StructTypeNode extends Node {
return (Math.ceil(offset / GPU_CHUNK_BYTES) * GPU_CHUNK_BYTES) / Float32Array.BYTES_PER_ELEMENT;
}

- getMemberType(builder, name) {
Expand Down Expand Up @@ -8021,7 +8026,7 @@ index 93c9419f..aa5b6b4b 100644

/**
diff --git a/src-testing/src/renderers/common/UniformsGroup.ts b/src-testing/src/renderers/common/UniformsGroup.ts
index 93cc042e..5ff6ce79 100644
index be2ca6bd..cf09d1ba 100644
--- a/src-testing/src/renderers/common/UniformsGroup.ts
+++ b/src-testing/src/renderers/common/UniformsGroup.ts
@@ -1,5 +1,15 @@
Expand Down Expand Up @@ -8087,7 +8092,7 @@ index 93cc042e..5ff6ce79 100644
let buffer = this._buffer;

if (buffer === null) {
@@ -171,14 +187,14 @@ class UniformsGroup extends UniformBuffer {
@@ -169,14 +185,14 @@ class UniformsGroup extends UniformBuffer {
* @param {Uniform} uniform - The uniform to update.
* @return {boolean} Whether the uniform has been updated or not.
*/
Expand All @@ -8110,7 +8115,7 @@ index 93cc042e..5ff6ce79 100644

console.error('THREE.WebGPUUniformsGroup: Unsupported uniform type.', uniform);
}
@@ -189,7 +205,7 @@ class UniformsGroup extends UniformBuffer {
@@ -187,7 +203,7 @@ class UniformsGroup extends UniformBuffer {
* @param {NumberUniform} uniform - The Number uniform.
* @return {boolean} Whether the uniform has been updated or not.
*/
Expand All @@ -8119,7 +8124,7 @@ index 93cc042e..5ff6ce79 100644
let updated = false;

const a = this.values;
@@ -213,7 +229,7 @@ class UniformsGroup extends UniformBuffer {
@@ -211,7 +227,7 @@ class UniformsGroup extends UniformBuffer {
* @param {Vector2Uniform} uniform - The Vector2 uniform.
* @return {boolean} Whether the uniform has been updated or not.
*/
Expand All @@ -8128,7 +8133,7 @@ index 93cc042e..5ff6ce79 100644
let updated = false;

const a = this.values;
@@ -239,7 +255,7 @@ class UniformsGroup extends UniformBuffer {
@@ -237,7 +253,7 @@ class UniformsGroup extends UniformBuffer {
* @param {Vector3Uniform} uniform - The Vector3 uniform.
* @return {boolean} Whether the uniform has been updated or not.
*/
Expand All @@ -8137,7 +8142,7 @@ index 93cc042e..5ff6ce79 100644
let updated = false;

const a = this.values;
@@ -266,7 +282,7 @@ class UniformsGroup extends UniformBuffer {
@@ -264,7 +280,7 @@ class UniformsGroup extends UniformBuffer {
* @param {Vector4Uniform} uniform - The Vector4 uniform.
* @return {boolean} Whether the uniform has been updated or not.
*/
Expand All @@ -8146,7 +8151,7 @@ index 93cc042e..5ff6ce79 100644
let updated = false;

const a = this.values;
@@ -294,7 +310,7 @@ class UniformsGroup extends UniformBuffer {
@@ -292,7 +308,7 @@ class UniformsGroup extends UniformBuffer {
* @param {ColorUniform} uniform - The Color uniform.
* @return {boolean} Whether the uniform has been updated or not.
*/
Expand All @@ -8155,7 +8160,7 @@ index 93cc042e..5ff6ce79 100644
let updated = false;

const a = this.values;
@@ -320,7 +336,7 @@ class UniformsGroup extends UniformBuffer {
@@ -318,7 +334,7 @@ class UniformsGroup extends UniformBuffer {
* @param {Matrix3Uniform} uniform - The Matrix3 uniform.
* @return {boolean} Whether the uniform has been updated or not.
*/
Expand All @@ -8164,7 +8169,7 @@ index 93cc042e..5ff6ce79 100644
let updated = false;

const a = this.values;
@@ -362,7 +378,7 @@ class UniformsGroup extends UniformBuffer {
@@ -360,7 +376,7 @@ class UniformsGroup extends UniformBuffer {
* @param {Matrix4Uniform} uniform - The Matrix4 uniform.
* @return {boolean} Whether the uniform has been updated or not.
*/
Expand All @@ -8173,7 +8178,7 @@ index 93cc042e..5ff6ce79 100644
let updated = false;

const a = this.values;
@@ -385,7 +401,7 @@ class UniformsGroup extends UniformBuffer {
@@ -383,7 +399,7 @@ class UniformsGroup extends UniformBuffer {
* @param {string} type - The data type.
* @return {TypedArray} The typed array.
*/
Expand All @@ -8182,7 +8187,7 @@ index 93cc042e..5ff6ce79 100644
if (type === 'int' || type === 'ivec2' || type === 'ivec3' || type === 'ivec4')
return new Int32Array(this.buffer.buffer);
if (type === 'uint' || type === 'uvec2' || type === 'uvec3' || type === 'uvec4')
@@ -402,7 +418,7 @@ class UniformsGroup extends UniformBuffer {
@@ -400,7 +416,7 @@ class UniformsGroup extends UniformBuffer {
* @param {TypedArray} b - The second array.
* @param {number} offset - An index offset for the first array.
*/
Expand All @@ -8191,7 +8196,7 @@ index 93cc042e..5ff6ce79 100644
for (let i = 0, l = b.length; i < l; i++) {
a[offset + i] = b[i];
}
@@ -417,7 +433,7 @@ function setArray(a, b, offset) {
@@ -415,7 +431,7 @@ function setArray(a, b, offset) {
* @param {number} offset - An index offset for the first array.
* @return {boolean} Whether the given arrays are equal or not.
*/
Expand Down
2 changes: 1 addition & 1 deletion three.js
Submodule three.js updated 39 files
+6 −6 build/three.cjs
+6 −6 build/three.core.js
+1 −1 build/three.core.min.js
+49 −14 build/three.webgpu.js
+1 −1 build/three.webgpu.min.js
+49 −14 build/three.webgpu.nodes.js
+1 −1 build/three.webgpu.nodes.min.js
+1 −0 examples/files.json
+1 −1 examples/jsm/exporters/DRACOExporter.js
+1 −1 examples/jsm/exporters/OBJExporter.js
+2 −2 examples/jsm/exporters/PLYExporter.js
+3 −4 examples/jsm/lines/LineMaterial.js
+4 −4 examples/jsm/loaders/ColladaLoader.js
+1 −1 examples/jsm/loaders/DRACOLoader.js
+8 −8 examples/jsm/loaders/FBXLoader.js
+53 −2 examples/jsm/loaders/LDrawLoader.js
+3 −3 examples/jsm/loaders/MTLLoader.js
+2 −2 examples/jsm/loaders/VRMLLoader.js
+18 −16 examples/jsm/objects/SkyMesh.js
+ examples/screenshots/webgl_random_uv.jpg
+ examples/screenshots/webgpu_compute_particles_fluid.jpg
+ examples/textures/noise.png
+433 −434 examples/webgpu_compute_cloth.html
+597 −0 examples/webgpu_compute_particles_fluid.html
+1 −1 examples/webgpu_lines_fat_raycasting.html
+0 −2 src/Three.TSL.js
+19 −11 src/materials/nodes/NodeMaterial.js
+7 −7 src/math/Color.js
+22 −3 src/math/ColorManagement.js
+19 −0 src/nodes/accessors/StorageBufferNode.js
+42 −0 src/nodes/core/NodeUtils.js
+24 −4 src/nodes/core/StructTypeNode.js
+4 −27 src/nodes/display/ColorSpaceNode.js
+14 −18 src/renderers/common/UniformsGroup.js
+12 −4 src/renderers/webgl-fallback/utils/WebGLTextureUtils.js
+22 −19 src/renderers/webgl-fallback/utils/WebGLUtils.js
+3 −1 src/renderers/webgpu/utils/WebGPUAttributeUtils.js
+24 −22 src/renderers/webgpu/utils/WebGPUTextureUtils.js
+1 −0 test/e2e/puppeteer.js
2 changes: 0 additions & 2 deletions types/three/src/Three.TSL.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,6 @@ export const time: typeof TSL.time;
export const timerDelta: typeof TSL.timerDelta;
export const timerGlobal: typeof TSL.timerGlobal;
export const timerLocal: typeof TSL.timerLocal;
export const toOutputColorSpace: typeof TSL.toOutputColorSpace;
export const toWorkingColorSpace: typeof TSL.toWorkingColorSpace;
export const toneMapping: typeof TSL.toneMapping;
export const toneMappingExposure: typeof TSL.toneMappingExposure;
export const toonOutlinePass: typeof TSL.toonOutlinePass;
Expand Down
14 changes: 12 additions & 2 deletions types/three/src/math/ColorManagement.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export interface ColorManagement {

convert: (color: Color, sourceColorSpace: string, targetColorSpace: string) => Color;

fromWorkingColorSpace: (color: Color, targetColorSpace: string) => Color;
workingToColorSpace: (color: Color, targetColorSpace: string) => Color;

toWorkingColorSpace: (color: Color, sourceColorSpace: string) => Color;
colorSpaceToWorking: (color: Color, sourceColorSpace: string) => Color;

getPrimaries: (colorSpace: string) => [number, number, number, number, number, number];

Expand All @@ -40,6 +40,16 @@ export interface ColorManagement {
getLuminanceCoefficients: (target: Vector3, colorSpace?: string) => [number, number, number];

define: (colorSpaces: Record<string, ColorSpaceDefinition>) => void;

/**
* @deprecated .fromWorkingColorSpace() has been renamed to .workingToColorSpace().
*/
fromWorkingColorSpace: (color: Color, targetColorSpace: string) => Color;

/**
* @deprecated .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().
*/
toWorkingColorSpace: (color: Color, sourceColorSpace: string) => Color;
}

export const ColorManagement: ColorManagement;
Expand Down
14 changes: 2 additions & 12 deletions types/three/src/nodes/display/ColorSpaceNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,13 @@ export default class ColorSpaceNode extends TempNode {
resolveColorSpace(nodeBuilder: NodeBuilder, colorSpace: WorkingOrOutputColorSpace): string;
}

export const toOutputColorSpace: (
node: NodeRepresentation,
) => ShaderNodeObject<ColorSpaceNode>;
export const toWorkingColorSpace: (
node: NodeRepresentation,
) => ShaderNodeObject<ColorSpaceNode>;

export const workingToColorSpace: (
node: NodeRepresentation,
colorSpace: string,
targetColorSpace: string,
) => ShaderNodeObject<ColorSpaceNode>;
export const colorSpaceToWorking: (
node: NodeRepresentation,
colorSpace: string,
sourceColorSpace: string,
) => ShaderNodeObject<ColorSpaceNode>;

export const convertColorSpace: (
Expand All @@ -51,9 +44,6 @@ export const convertColorSpace: (

declare module "../tsl/TSLCore.js" {
interface NodeElements {
toOutputColorSpace: typeof toOutputColorSpace;
toWorkingColorSpace: typeof toWorkingColorSpace;

workingToColorSpace: typeof workingToColorSpace;
colorSpaceToWorking: typeof colorSpaceToWorking;
}
Expand Down
Loading