Initial project import
This commit is contained in:
29
node_modules/@react-three/drei/core/MultiMaterial.js
generated
vendored
Normal file
29
node_modules/@react-three/drei/core/MultiMaterial.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import _extends from '@babel/runtime/helpers/esm/extends';
|
||||
import * as React from 'react';
|
||||
|
||||
function MultiMaterial(props) {
|
||||
const group = React.useRef(null);
|
||||
React.useLayoutEffect(() => {
|
||||
const parent = group.current.parent;
|
||||
const geometry = parent == null ? void 0 : parent.geometry;
|
||||
if (geometry) {
|
||||
const oldMaterial = parent.material;
|
||||
parent.material = group.current.__r3f.children.map(instance => instance.object);
|
||||
const oldGroups = [...geometry.groups];
|
||||
geometry.clearGroups();
|
||||
parent.material.forEach((material, index) => {
|
||||
if (index < parent.material.length - 1) material.depthWrite = false;
|
||||
geometry.addGroup(0, Infinity, index);
|
||||
});
|
||||
return () => {
|
||||
parent.material = oldMaterial;
|
||||
geometry.groups = oldGroups;
|
||||
};
|
||||
}
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("group", _extends({
|
||||
ref: group
|
||||
}, props));
|
||||
}
|
||||
|
||||
export { MultiMaterial };
|
||||
Reference in New Issue
Block a user