Clipping Planes Imported Custom Material Problem

I’ve been working on a project that uses clipping planes.
I’ve gotten multiple objects w/ materials loaded from Blender, fine and dandy.
However I’m having one problem.
The code I’m using and changed from the stencil code example here with (live demo of the examples code here) has a new object created with new materials.

I am loading my own objects to use, and want to use my own materials.
I’ve done the loading of the materials from the loaded object and adding the properties to them that the example code does.

that would be (from line 175):
clippingPlanes: planes, clipShadows: true, shadowSide: v3d.DoubleSide,

(which works fine for the main parts of the object, no problem there)

this issue is importing my own material into the ‘planeMat’ material (the material made for the geometry that is sliced at the clipping plane)

I do the same importing and adding of properties, but it bugs out. serous graphic artifacts.
I believe it’s because it’s in a loop for each plane.
where on line 150
which is:
clippingPlanes: planes.filter(p => p !== plane),
…needs to be iterated with each plane (3) intersection’s geometry.

I have the desired material from Blender stored in a var ‘material_Clip’.
after i load it, i append to it…
`console.log('material_Clip BEFORE appending clipping planes and stencil: ',

// this line omitted for some attempts
// material_Clip.clippingPlanes= planes.filter(p => p !== plane),
material_Clip.stencilWrite = true,
material_Clip.stencilRef = 0,
material_Clip.stencilFunc = THREE.NotEqualStencilFunc,
material_Clip.stencilFail = THREE.ReplaceStencilOp,
material_Clip.stencilZFail = THREE.ReplaceStencilOp,
material_Clip.stencilZPass = THREE.ReplaceStencilOp, = 'material_Clip',

console.log('material_Clip AFTER appending clipping planes and stencil: ',

How would any of you have your own imported material go through that loop to be appended with the iterated attributes?


P.S. my material from blender is a NodeMaterial, wonder if there are incompatibility issues here with the attributes.

Can you make a jsfiddle demonstrating the problem? Do the custom materials you’re using support clipping planes?

I could try a fiddle. I’d like to first find out if node materials do or do not support clipping Planes. Trying to find out in the docs.

It’s identical to the material I import for the body of the object (besides the appended properties) and that one works fine.

The material actually doesn’t “have” to be the one imported. (Though I hate problems not solved) …i just need the sliced material (planeMat) to match the metal of the body geometry and its environment lighting reflection map.

It’s there a way to copy material properties?

It’s there a way to copy material properties?

If you just mean the material properties like color, roughness, stencilWrite, etc there’s no guaranteed built in way to copy between two different material types as far as I know. I’m unfamiliar with NodeMaterial, though.

I fixed it with the .copy(material) method of the Material object.

after doing the appending i did above without the iterated line
i did:
var planeMat = new THREE.MeshNodeMaterial(); planeMat.copy(material_Clip); planeMat.clippingPlanes= planes.filter(p => p !== plane)

all working fine, with my imported node materials now!