-
-
Notifications
You must be signed in to change notification settings - Fork 36k
Closed
Description
Description
As the title says.
Reproduction steps
- Copy the code into
index.html
- Run it on browser
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>three.js WebGPU</title>
<style>
:root {
color-scheme: light dark;
}
body {
margin: 0;
}
</style>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/[email protected]/build/three.webgpu.js",
"three/addons/": "https://unpkg.com/[email protected]/examples/jsm/",
"three/webgpu": "https://unpkg.com/[email protected]/build/three.webgpu.js",
"three/tsl": "https://unpkg.com/[email protected]/build/three.tsl.js"
}
}
</script>
</head>
<body>
<script type="module">
import { AmbientLight, BoxGeometry, DirectionalLight, HemisphereLight, Mesh, MeshPhongNodeMaterial, PerspectiveCamera, PlaneGeometry, Scene, ShadowNodeMaterial, WebGPURenderer } from 'three/webgpu'
const scene = new Scene()
const camera = new PerspectiveCamera(50, window.innerWidth / window.innerHeight)
camera.position.set( 5, 5, 5 )
camera.lookAt(0, 0, 0)
const renderer = new WebGPURenderer()
renderer.shadowMap.enabled = true
renderer.setPixelRatio( window.devicePixelRatio )
renderer.setSize( window.innerWidth, window.innerHeight )
document.body.appendChild( renderer.domElement )
scene.add(new AmbientLight(0xffffff, 1))
scene.add(new HemisphereLight(0xffffff, 0x000000, 1))
const light = new DirectionalLight(0xffffff, 1)
// light.castShadow = true // Uncaught (in promise) TypeError: Cannot read properties of null (reading 'getNodeType')
light.position.set(-1, 1, 1)
scene.add(light)
const plane = new Mesh(new PlaneGeometry(10, 10, 10), new ShadowNodeMaterial())
plane.receiveShadow = true
plane.rotation.x = -Math.PI / 2
plane.position.set(0, -0.5, 0)
scene.add(plane)
const geometry = new BoxGeometry()
const material = new MeshPhongNodeMaterial()
const mesh = new Mesh(geometry, material)
mesh.castShadow = true
scene.add(mesh)
renderer.render( scene, camera )
</script>
</body>
</html>
Live example
None
Screenshots
No response
Version
r176
Device
Desktop
Browser
Chrome, Edge
OS
Linux
Mugen87