From 7c3912e69bd30863f0638679ff34cec140f57dd4 Mon Sep 17 00:00:00 2001 From: syui Date: Tue, 19 Mar 2024 02:11:43 +0900 Subject: [PATCH] fix --- dist/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/main.js b/dist/main.js index b77fdfd0e..45a6a3cc6 100644 --- a/dist/main.js +++ b/dist/main.js @@ -36,7 +36,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \**********************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { -eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst THREE = __webpack_require__(/*! three */ \"./node_modules/three/build/three.cjs\");\nconst GLTFLoader_1 = __webpack_require__(/*! three/examples/jsm/loaders/GLTFLoader */ \"./node_modules/three/examples/jsm/loaders/GLTFLoader.js\");\nconst OrbitControls_1 = __webpack_require__(/*! three/examples/jsm/controls/OrbitControls */ \"./node_modules/three/examples/jsm/controls/OrbitControls.js\");\nconst three_vrm_1 = __webpack_require__(/*! @pixiv/three-vrm */ \"./node_modules/@pixiv/three-vrm/lib/three-vrm.module.js\");\nconst three_vrm_animation_1 = __webpack_require__(/*! @pixiv/three-vrm-animation */ \"./node_modules/@pixiv/three-vrm-animation/lib/three-vrm-animation.module.js\");\nconst three_1 = __webpack_require__(/*! three */ \"./node_modules/three/build/three.cjs\");\nconst three_2 = __webpack_require__(/*! three */ \"./node_modules/three/build/three.cjs\");\nwindow.addEventListener(\"DOMContentLoaded\", () => {\n const canvas = document.getElementById(\"canvas\");\n if (canvas == null)\n return;\n const scene = new THREE.Scene();\n const camera = new THREE.PerspectiveCamera(30, canvas.clientWidth / canvas.clientHeight, 0.1, 20);\n camera.position.set(0.0, 0.9, -4.0);\n camera.rotation.set(0.0, Math.PI, 0.0);\n camera.lookAt(new THREE.Vector3(0, 0, 0));\n const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });\n renderer.setPixelRatio(window.devicePixelRatio);\n renderer.setSize(canvas.clientWidth, canvas.clientHeight);\n renderer.setClearColor(0x7fbfff, 1.0);\n renderer.shadowMap.enabled = true;\n renderer.outputColorSpace = THREE.SRGBColorSpace;\n //renderer.toneMapping = THREE.ACESFilmicToneMapping;\n //renderer.toneMappingExposure = 1;\n canvas.appendChild(renderer.domElement);\n const light = new THREE.DirectionalLight(0xffffff, Math.PI);\n light.position.set(1.0, 1.0, 1.0);\n scene.add(light);\n let currentVrm = undefined;\n let currentVrmAnimation = undefined;\n let currentMixer = undefined;\n function load(url) {\n loader.load(url, (gltf) => {\n tryInitVRM(gltf);\n tryInitVRMA(gltf);\n }, (progress) => console.log(\"Loading model...\", 100.0 * (progress.loaded / progress.total), \"%\"), (error) => console.error(error));\n }\n function tryInitVRM(gltf) {\n const vrm = gltf.userData.vrm;\n if (vrm == null) {\n return;\n }\n currentVrm = vrm;\n scene.add(vrm.scene);\n initAnimationClip();\n }\n function tryInitVRMA(gltf) {\n var _a;\n const vrmAnimations = gltf.userData.vrmAnimations;\n if (vrmAnimations == null) {\n return;\n }\n currentVrmAnimation = (_a = vrmAnimations[0]) !== null && _a !== void 0 ? _a : null;\n initAnimationClip();\n }\n function initAnimationClip() {\n if (currentVrm && currentVrmAnimation) {\n currentMixer = new THREE.AnimationMixer(currentVrm.scene);\n const clip = (0, three_vrm_animation_1.createVRMAnimationClip)(currentVrmAnimation, currentVrm);\n currentMixer.clipAction(clip).play();\n }\n }\n const loader = new GLTFLoader_1.GLTFLoader();\n loader.register((parser) => {\n return new three_vrm_1.VRMLoaderPlugin(parser);\n });\n loader.register((parser) => {\n return new three_vrm_animation_1.VRMAnimationLoaderPlugin(parser);\n });\n load(\"/vrma/ai.vrm\");\n load(\"/vrma/fly_c.vrma\");\n const clock = new THREE.Clock();\n clock.start();\n const update = () => {\n controls.update();\n requestAnimationFrame(update);\n const deltaTime = clock.getDelta();\n if (currentMixer) {\n currentMixer.update(deltaTime);\n }\n if (currentVrm) {\n currentVrm.update(deltaTime);\n }\n renderer.render(scene, camera);\n };\n scene.background = new THREE.Color(0xffffff);\n const directionalLight = new THREE.DirectionalLight(0xffffff);\n directionalLight.position.set(1, 1, 1);\n scene.add(directionalLight);\n const ambientLight = new THREE.AmbientLight(0x333333);\n scene.add(ambientLight);\n const controls = new OrbitControls_1.OrbitControls(camera, renderer.domElement);\n controls.enableDamping = true;\n controls.dampingFactor = 0.2;\n controls.enableRotate = true;\n controls.target.set(0.0, 1.0, 0.0);\n function floor_default() {\n const floor = new three_2.Mesh(new three_2.BoxGeometry(50, 100), new three_2.MeshLambertMaterial({\n color: 0xffffff,\n depthWrite: true,\n }));\n floor.position.y = -1.0;\n floor.rotation.x = -Math.PI / 2;\n scene.add(floor);\n }\n function floor_grid() {\n const grid = new three_2.GridHelper(50, 100, 0xffffff, 0xffffff);\n scene.add(grid);\n grid.position.set(Math.round(0), 0, Math.round(0));\n }\n function floor_bg() {\n var _a;\n scene.fog = new three_1.Fog(0xffffff, 3, 20);\n (_a = scene.fog) === null || _a === void 0 ? void 0 : _a.color.set(0xffffff);\n }\n floor_default();\n floor_grid();\n floor_bg();\n update();\n setInterval(() => {\n const r = Math.floor(Math.random() * 4 + 1);\n load(\"/vrma/\" + r + \".vrma\");\n setTimeout(() => {\n load(\"/vrma/fly_c.vrma\");\n }, 10000);\n }, 15000);\n});\n\n\n//# sourceURL=webpack://vrm/./src/index.ts?"); +eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst THREE = __webpack_require__(/*! three */ \"./node_modules/three/build/three.cjs\");\nconst GLTFLoader_1 = __webpack_require__(/*! three/examples/jsm/loaders/GLTFLoader */ \"./node_modules/three/examples/jsm/loaders/GLTFLoader.js\");\nconst OrbitControls_1 = __webpack_require__(/*! three/examples/jsm/controls/OrbitControls */ \"./node_modules/three/examples/jsm/controls/OrbitControls.js\");\nconst three_vrm_1 = __webpack_require__(/*! @pixiv/three-vrm */ \"./node_modules/@pixiv/three-vrm/lib/three-vrm.module.js\");\nconst three_vrm_animation_1 = __webpack_require__(/*! @pixiv/three-vrm-animation */ \"./node_modules/@pixiv/three-vrm-animation/lib/three-vrm-animation.module.js\");\nconst three_1 = __webpack_require__(/*! three */ \"./node_modules/three/build/three.cjs\");\nconst three_2 = __webpack_require__(/*! three */ \"./node_modules/three/build/three.cjs\");\nwindow.addEventListener(\"DOMContentLoaded\", () => {\n const canvas = document.getElementById(\"canvas\");\n if (canvas == null)\n return;\n const scene = new THREE.Scene();\n const camera = new THREE.PerspectiveCamera(30, canvas.clientWidth / canvas.clientHeight, 0.1, 20);\n camera.position.set(0.0, 0.9, -4.0);\n camera.rotation.set(0.0, Math.PI, 0.0);\n camera.lookAt(new THREE.Vector3(0, 0, 0));\n // https://threejs.org/docs/#api/en/constants/Renderer\n const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });\n renderer.setPixelRatio(window.devicePixelRatio);\n renderer.setSize(canvas.clientWidth, canvas.clientHeight);\n renderer.setClearColor(0x7fbfff, 1.0);\n renderer.shadowMap.enabled = true;\n renderer.outputColorSpace = THREE.SRGBColorSpace;\n renderer.toneMapping = THREE.ReinhardToneMapping;\n renderer.toneMapping = THREE.NeutralToneMapping;\n canvas.appendChild(renderer.domElement);\n renderer.toneMappingExposure = 1.5;\n //renderer.toneMapping = THREE.ACESFilmicToneMapping;\n const light = new THREE.DirectionalLight(0xffffff, Math.PI);\n light.position.set(1.0, 1.0, 1.0);\n scene.add(light);\n let currentVrm = undefined;\n let currentVrmAnimation = undefined;\n let currentMixer = undefined;\n function load(url) {\n loader.load(url, (gltf) => {\n tryInitVRM(gltf);\n tryInitVRMA(gltf);\n }, (progress) => console.log(\"Loading model...\", 100.0 * (progress.loaded / progress.total), \"%\"), (error) => console.error(error));\n }\n function tryInitVRM(gltf) {\n const vrm = gltf.userData.vrm;\n if (vrm == null) {\n return;\n }\n currentVrm = vrm;\n scene.add(vrm.scene);\n initAnimationClip();\n }\n function tryInitVRMA(gltf) {\n var _a;\n const vrmAnimations = gltf.userData.vrmAnimations;\n if (vrmAnimations == null) {\n return;\n }\n currentVrmAnimation = (_a = vrmAnimations[0]) !== null && _a !== void 0 ? _a : null;\n initAnimationClip();\n }\n function initAnimationClip() {\n if (currentVrm && currentVrmAnimation) {\n currentMixer = new THREE.AnimationMixer(currentVrm.scene);\n const clip = (0, three_vrm_animation_1.createVRMAnimationClip)(currentVrmAnimation, currentVrm);\n currentMixer.clipAction(clip).play();\n }\n }\n const loader = new GLTFLoader_1.GLTFLoader();\n loader.register((parser) => {\n return new three_vrm_1.VRMLoaderPlugin(parser);\n });\n loader.register((parser) => {\n return new three_vrm_animation_1.VRMAnimationLoaderPlugin(parser);\n });\n load(\"/vrma/ai.vrm\");\n load(\"/vrma/fly_c.vrma\");\n const clock = new THREE.Clock();\n clock.start();\n const update = () => {\n controls.update();\n requestAnimationFrame(update);\n const deltaTime = clock.getDelta();\n if (currentMixer) {\n currentMixer.update(deltaTime);\n }\n if (currentVrm) {\n currentVrm.update(deltaTime);\n }\n renderer.render(scene, camera);\n };\n scene.background = new THREE.Color(0xffffff);\n const directionalLight = new THREE.DirectionalLight(0xffffff);\n directionalLight.position.set(1, 1, 1);\n scene.add(directionalLight);\n const ambientLight = new THREE.AmbientLight(0x333333);\n scene.add(ambientLight);\n const controls = new OrbitControls_1.OrbitControls(camera, renderer.domElement);\n controls.enableDamping = true;\n controls.dampingFactor = 0.2;\n controls.enableRotate = true;\n controls.target.set(0.0, 1.0, 0.0);\n function floor_default() {\n const floor = new three_2.Mesh(new three_2.BoxGeometry(50, 100), new three_2.MeshLambertMaterial({\n color: 0xffffff,\n depthWrite: true,\n }));\n floor.position.y = -1.0;\n floor.rotation.x = -Math.PI / 2;\n floor.name = \"floor\";\n scene.add(floor);\n }\n function floor_grid() {\n const grid = new three_2.GridHelper(50, 100, 0xffffff, 0xffffff);\n scene.add(grid);\n grid.position.set(Math.round(0), 0, Math.round(0));\n }\n function floor_bg() {\n var _a;\n scene.fog = new three_1.Fog(0xffffff, 3, 20);\n (_a = scene.fog) === null || _a === void 0 ? void 0 : _a.color.set(0xffffff);\n }\n floor_default();\n floor_grid();\n floor_bg();\n update();\n function animate() {\n requestAnimationFrame(animate);\n scene.rotation.y += 0.005;\n renderer.render(scene, camera);\n }\n animate();\n function random_happy() {\n // https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_vrm-1.0/expressions.ja.md\n currentVrm.expressionManager.setValue('relaxed', 0.5);\n }\n function random_head() {\n // https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_vrm-1.0/lookAt.ja.md\n currentVrm.lookAt.target = camera;\n currentVrm.VRMLookAtBoneApplier = camera;\n currentVrm.VRMLookAtExpressionApplier = camera;\n // https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_vrm-1.0/humanoid.ja.md\n const head = currentVrm.humanoid.getRawBoneNode(\"head\");\n head.target = camera;\n }\n function random_blink() {\n setInterval(() => {\n currentVrm.expressionManager.setValue('relaxed', 0);\n currentVrm.expressionManager.setValue('blink', 0);\n random_head();\n const r = Math.floor(Math.random() * 3);\n if (r == 1) {\n setTimeout(() => { currentVrm.expressionManager.setValue('blink', 1); }, 5000);\n setTimeout(() => {\n currentVrm.expressionManager.setValue('blink', 0);\n }, 5500);\n }\n ;\n setTimeout(() => {\n currentVrm.expressionManager.setValue('relaxed', 0.5);\n currentVrm.expressionManager.setValue('blink', 1);\n }, 6000);\n }, 6500);\n }\n random_blink();\n setInterval(() => {\n const r = Math.floor(Math.random() * 4 + 1);\n load(\"/vrma/\" + r + \".vrma\");\n setTimeout(() => {\n load(\"/vrma/fly_c.vrma\");\n }, 10000);\n }, 15000);\n function light_off() {\n renderer.toneMapping = THREE.ACESFilmicToneMapping;\n light.intensity = -0.5;\n scene.background = new THREE.Color(0x000000);\n scene.fog = new three_1.Fog(0x000000, 3, 20);\n }\n //light_off();\n});\n\n\n//# sourceURL=webpack://vrm/./src/index.ts?"); /***/ }),