UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

27 lines (26 loc) 907 B
import { BLEND_NORMAL } from "../../../../scene/constants.js"; import { extractTextureTransform } from "./khr-texture-transform.js"; const KHR_materials_volume = { apply(data, material, textures) { material.blendType = BLEND_NORMAL; material.useDynamicRefraction = true; if (data.hasOwnProperty("thicknessFactor")) { material.thickness = data.thicknessFactor; } if (data.hasOwnProperty("thicknessTexture")) { material.thicknessMap = textures[data.thicknessTexture.index]; material.thicknessMapChannel = "g"; extractTextureTransform(data.thicknessTexture, material, ["thickness"]); } if (data.hasOwnProperty("attenuationDistance")) { material.attenuationDistance = data.attenuationDistance; } if (data.hasOwnProperty("attenuationColor")) { const [r, g, b] = data.attenuationColor; material.attenuation.set(r, g, b).gamma(); } } }; export { KHR_materials_volume };