Skip to content

Commit

Permalink
browser experiment.
Browse files Browse the repository at this point in the history
  • Loading branch information
syoyo committed Aug 15, 2024
1 parent c92356b commit 1a5b5a2
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sandbox/threejs/simple/TinyUSDZLoader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let TinyUSDZ = null;

const TINYUSDZ_PATH = './tinyusdz.js';

async function TinyUSDZLoader() {
if ( TinyUSDZ === null ) {

const { default: initTinyUSDZ } = await import( TINYUSDZ_PATH );
TinyUSDZ = await initTinyUSDZ();

}

console.log( TinyUSDZ );
}

export { TinyUSDZLoader };
15 changes: 15 additions & 0 deletions sandbox/threejs/simple/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My first three.js app</title>
<style>
body { margin: 0; }
</style>
</head>
<body>
<script>
</script>
<script type="module" src="/main.js"></script>
</body>
</html>
30 changes: 30 additions & 0 deletions sandbox/threejs/simple/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as THREE from 'three';

import * as TinyUSDZLoader from './TinyUSDZLoader'

const usd = TinyUSDZLoader.TinyUSDZLoader();
//const usd = new TinyUSDZLoader.TinyU( )

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );

const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
document.body.appendChild( renderer.domElement );

const geometry = new THREE.BoxGeometry( 1, 1, 1 );
const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );

camera.position.z = 5;

function animate() {

cube.rotation.x += 0.01;
cube.rotation.y += 0.01;

renderer.render( scene, camera );

}
24 changes: 24 additions & 0 deletions sandbox/threejs/simple/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "simple-threejs-tinyusdzloader",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"devDependencies": {
"@types/three": "^0.160.0",
"typescript": "^5.2.2",
"vite": "^5.0.8",
"@types/bun": "latest"
},
"dependencies": {
"gsap": "^3.12.4",
"lil-gui": "^0.19.1",
"stats.js": "^0.17.0",
"three": "^0.160.0"
},
"module": "index.ts"
}

0 comments on commit 1a5b5a2

Please sign in to comment.