Skip to content

FuriouZz/deno_webgpu_canvas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deno_webgpu_canvas

The goal of this project is to experiment how to run a THREE.JS project outside a browser.

import {
  BoxGeometry,
  Mesh,
  Scene,
  MeshNormalMaterial,
  PerspectiveCamera,
} from "https://esm.sh/three";
import WebGPURenderer from "https://esm.sh/three/addons/renderers/webgpu/WebGPURenderer.js";
import { OrbitControls } from "https://esm.sh/three/addons/controls/OrbitControls.js";
import { WebGPUCanvas } from "deno_webgpu_canvas/mod.ts";

const title = "ThreeJS";
const width = 800;
const height = 600;

const canvas = new WebGPUCanvas({ title, width, height });

const renderer = new WebGPURenderer({ canvas });
await renderer.init();
renderer.setSize(width, height, false);

const scene = new Scene();
const camera = new PerspectiveCamera(75, 800 / 600, 0.1, 1000);
camera.updateProjectionMatrix();
camera.position.z = 5;

const controls = new OrbitControls(camera, canvas);

const cube = new Mesh(new BoxGeometry(1, 1, 1), new MeshNormalMaterial());
scene.add(cube);

canvas.addEventListener("draw", () => {
  controls.update();
  renderer.render(scene, camera);
});

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published