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
32 changes: 16 additions & 16 deletions examples/webgpu_materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@

material = new THREE.MeshBasicNodeMaterial();
material.colorNode = scriptableNode;
//materials.push( material );
materials.push( material );

scriptableNode.setLocal( 'material', material );

Expand All @@ -349,7 +349,7 @@

}

// const serializeMesh = scene.children[ scene.children.length - 1 ];
const serializeMesh = scene.children[ scene.children.length - 1 ];

//

Expand All @@ -370,7 +370,7 @@

//

// setTimeout( () => testSerialization( serializeMesh ), 1000 ); // FIXME, see #28933
setTimeout( () => testSerialization( serializeMesh ), 1000 ); // FIXME, see #28933
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mugen87 Do you need to remove the inline comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is rendering a black teapot on a black background. It does not appear to be working as intended...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is an issue with the material but this should be unrelated to serialization/deserialization. Probably best to file a separate issue for this.


}

Expand All @@ -391,26 +391,26 @@

}

// function testSerialization( mesh ) {
function testSerialization( mesh ) {

// const json = mesh.toJSON();
// const loader = new THREE.NodeObjectLoader();
// const serializedMesh = loader.parse( json );
const json = mesh.toJSON();
const loader = new THREE.NodeObjectLoader();
const serializedMesh = loader.parse( json );

// serializedMesh.position.x = ( objects.length % 4 ) * 200 - 400;
// serializedMesh.position.z = Math.floor( objects.length / 4 ) * 200 - 200;
serializedMesh.position.x = ( objects.length % 4 ) * 200 - 400;
serializedMesh.position.z = Math.floor( objects.length / 4 ) * 200 - 200;

// const scriptableNode = serializedMesh.material.colorNode;
const scriptableNode = serializedMesh.material.colorNode;

// // it's because local.get( 'material' ) is used in the example ( local/global is unserializable )
// scriptableNode.setLocal( 'material', serializedMesh.material );
// scriptableNode.setParameter( 'execFrom', 'serialized' );
// it's because local.get( 'material' ) is used in the example ( local/global is unserializable )
scriptableNode.setLocal( 'material', serializedMesh.material );
scriptableNode.setParameter( 'execFrom', 'serialized' );

// objects.push( serializedMesh );
objects.push( serializedMesh );

// scene.add( serializedMesh );
scene.add( serializedMesh );

// }
}

function onWindowResize() {

Expand Down
4 changes: 2 additions & 2 deletions examples/webgpu_multisampled_renderbuffers.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
// textured mesh

const geometryBox = new THREE.BoxGeometry( 7, 7, 7, 12, 12, 12 );
const materialBox = new THREE.MeshPhongNodeMaterial();
const materialBoxInner = new THREE.MeshPhongNodeMaterial( { color: 0xff0000 } );
const materialBox = new THREE.MeshBasicNodeMaterial();
const materialBoxInner = new THREE.MeshBasicNodeMaterial( { color: 0xff0000 } );

materialBox.wireframe = true;

Expand Down
6 changes: 6 additions & 0 deletions src/nodes/accessors/TextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ class TextureNode extends UniformNode {
super.serialize( data );

data.value = this.value.toJSON( data.meta ).uuid;
data.sampler = this.sampler;
data.updateMatrix = this.updateMatrix;
data.updateType = this.updateType;

}

Expand All @@ -395,6 +398,9 @@ class TextureNode extends UniformNode {
super.deserialize( data );

this.value = data.meta.textures[ data.value ];
this.sampler = data.sampler;
this.updateMatrix = data.updateMatrix;
this.updateType = data.updateType;

}

Expand Down
20 changes: 20 additions & 0 deletions src/nodes/core/UniformGroupNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ class UniformGroupNode extends Node {

}

serialize( data ) {

super.serialize( data );

data.name = this.name;
data.version = this.version;
data.shared = this.shared;

}

deserialize( data ) {

super.deserialize( data );

this.name = data.name;
this.version = data.version;
this.shared = data.shared;

}

}

export const uniformGroup = ( name ) => new UniformGroupNode( name );
Expand Down