1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
| const gltfLoader = new GLTFLoader(); const dracoLoader = new DRACOLoader(); dracoLoader.setDecoderPath("./draco/"); gltfLoader.setDRACOLoader(dracoLoader); gltfLoader.load( "./model/cup.glb", (gltf) => { let cup = gltf.scene.getObjectByName("copo_low_01_vidro_0"); let water = gltf.scene.getObjectByName("copo_low_02_agua_0"); let ice = gltf.scene.getObjectByName("copo_low_04_vidro_0");
ice.scale.set(0.86, 0.86, 0.86); water.position.z = -1; ice.renderOrder = 1; water.renderOrder = 2; cup.renderOrder = 3;
console.log("ice", ice); console.log("water", water); let iceMaterial = ice.material; ice.material = new THREE.MeshPhysicalMaterial({ normalMap: iceMaterial.normalMap, metalnessMap: iceMaterial.metalnessMap, roughness: 0, color: 0xffffff, transmission: 0.95, transparent: true, thickness: 10, ior: 2, });
let waterMaterial = water.material; water.material = new THREE.MeshPhysicalMaterial({ map: waterMaterial.map, normalMap: waterMaterial.normalMap, metalnessMap: waterMaterial.metalnessMap, roughnessMap: waterMaterial.roughnessMap, transparent: true, transmission: 0.95, roughness: 0.1, thickness: 10, ior: 2, });
cup.material = new THREE.MeshPhysicalMaterial({ map: cup.material.map, normalMap: cup.material.normalMap, metalnessMap: cup.material.metalnessMap, roughnessMap: cup.material.roughnessMap, transparent: true, transmission: 0.95, roughness: 0.3, thickness: 10, ior: 2, opacity: 0.6, });
let material = water.material; material.blending = THREE.CustomBlending; material.blendEquation = THREE.AddEquation; material.blendSrc = THREE.SrcAlphaFactor; material.blendDst = THREE.SrcColorFactor;
cup.material.blending = THREE.CustomBlending; cup.material.blendEquation = THREE.AddEquation; cup.material.blendSrc = THREE.SrcAlphaFactor; cup.material.blendDst = THREE.SrcColorFactor;
gui .add(material, "blendEquation", { AddEquation: THREE.AddEquation, SubtractEquation: THREE.SubtractEquation, ReverseSubtractEquation: THREE.ReverseSubtractEquation, MinEquation: THREE.MinEquation, MaxEquation: THREE.MaxEquation, }) .name("blendEquation");
gui .add(material, "blendSrc", { ZeroFactor: THREE.ZeroFactor, OneFactor: THREE.OneFactor, SrcColorFactor: THREE.SrcColorFactor, OneMinusSrcColorFactor: THREE.OneMinusSrcColorFactor, SrcAlphaFactor: THREE.SrcAlphaFactor, OneMinusSrcAlphaFactor: THREE.OneMinusSrcAlphaFactor, DstAlphaFactor: THREE.DstAlphaFactor, OneMinusDstAlphaFactor: THREE.OneMinusDstAlphaFactor, DstColorFactor: THREE.DstColorFactor, OneMinusDstColorFactor: THREE.OneMinusDstColorFactor, SrcAlphaSaturateFactor: THREE.SrcAlphaSaturateFactor, }) .name("blendSrc"); gui .add(cup.material, "blendDst", { ZeroFactor: THREE.ZeroFactor, OneFactor: THREE.OneFactor, SrcColorFactor: THREE.SrcColorFactor, OneMinusSrcColorFactor: THREE.OneMinusSrcColorFactor, SrcAlphaFactor: THREE.SrcAlphaFactor, OneMinusSrcAlphaFactor: THREE.OneMinusSrcAlphaFactor, DstAlphaFactor: THREE.DstAlphaFactor, OneMinusDstAlphaFactor: THREE.OneMinusDstAlphaFactor, DstColorFactor: THREE.DstColorFactor, OneMinusDstColorFactor: THREE.OneMinusDstColorFactor, }) .name("blendDst");
gui .add(material, "blendEquationAlpha", { AddEquation: THREE.AddEquation, SubtractEquation: THREE.SubtractEquation, ReverseSubtractEquation: THREE.ReverseSubtractEquation, MinEquation: THREE.MinEquation, MaxEquation: THREE.MaxEquation, }) .name("blendEquationAlpha");
gui .add(material, "blendSrcAlpha", { ZeroFactor: THREE.ZeroFactor, OneFactor: THREE.OneFactor, SrcColorFactor: THREE.SrcColorFactor, OneMinusSrcColorFactor: THREE.OneMinusSrcColorFactor, SrcAlphaFactor: THREE.SrcAlphaFactor, OneMinusSrcAlphaFactor: THREE.OneMinusSrcAlphaFactor, DstAlphaFactor: THREE.DstAlphaFactor, OneMinusDstAlphaFactor: THREE.OneMinusDstAlphaFactor, DstColorFactor: THREE.DstColorFactor, OneMinusDstColorFactor: THREE.OneMinusDstColorFactor, SrcAlphaSaturateFactor: THREE.SrcAlphaSaturateFactor, }) .name("blendSrcAlpha"); gui.add(material, "blendDstAlpha", { ZeroFactor: THREE.ZeroFactor, OneFactor: THREE.OneFactor, SrcColorFactor: THREE.SrcColorFactor, OneMinusSrcColorFactor: THREE.OneMinusSrcColorFactor, SrcAlphaFactor: THREE.SrcAlphaFactor, OneMinusSrcAlphaFactor: THREE.OneMinusSrcAlphaFactor, DstAlphaFactor: THREE.DstAlphaFactor, OneMinusDstAlphaFactor: THREE.OneMinusDstAlphaFactor, DstColorFactor: THREE.DstColorFactor, OneMinusDstColorFactor: THREE.OneMinusDstColorFactor, }); scene.add(gltf.scene); } );
|