mirror of
https://github.com/storytold/spark.git
synced 2026-10-26 08:47:57 +00:00
Point README to CDN
This commit is contained in:
@@ -46,38 +46,39 @@ Check out all the [examples]()
|
|||||||
Copy the following code into an `index.html` file.
|
Copy the following code into an `index.html` file.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<style> body {margin: 0;} </style>
|
<style> body {margin: 0;} </style>
|
||||||
<script type="importmap">
|
<script type="importmap">
|
||||||
{
|
{
|
||||||
"imports": {
|
"imports": {
|
||||||
"three": "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.174.0/three.module.js",
|
"three": "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.174.0/three.module.js",
|
||||||
"@forge-gfx/forge": "cdn/url/to/forge.module.js"
|
"@worldlabsai/forge": "https://forge.dev/releases/forge/0.1.0/forge.module.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import { SplatMesh } from "@forge-gfx/forge";
|
import { SplatMesh } from "@worldlabsai/forge";
|
||||||
|
|
||||||
const scene = new THREE.Scene();
|
const scene = new THREE.Scene();
|
||||||
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000);
|
||||||
const renderer = new THREE.WebGLRenderer();
|
const renderer = new THREE.WebGLRenderer();
|
||||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||||
document.body.appendChild(renderer.domElement)
|
document.body.appendChild(renderer.domElement)
|
||||||
|
|
||||||
const butterfly = new SplatMesh({ url: "cdn/url/to/butterfly.spz"});
|
const splatURL = "https://forge.dev/assets/splats/butterfly.spz";
|
||||||
butterfly.quaternion.set(1, 0, 0, 0);
|
const butterfly = new SplatMesh({ url: splatURL });
|
||||||
butterfly.position.set(0, 0, -1);
|
butterfly.quaternion.set(1, 0, 0, 0);
|
||||||
scene.add(butterfly);
|
butterfly.position.set(0, 0, -3);
|
||||||
|
scene.add(butterfly);
|
||||||
|
|
||||||
renderer.setAnimationLoop(function animate(time) {
|
renderer.setAnimationLoop(function animate(time) {
|
||||||
renderer.render(scene, camera);
|
renderer.render(scene, camera);
|
||||||
butterfly.rotation.y += 0.01;
|
butterfly.rotation.y += 0.01;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [Run Examples](#run-examples) section below to try out other examples.
|
See the [Run Examples](#run-examples) section below to try out other examples.
|
||||||
|
|
||||||
### Web Editor
|
### Web Editor
|
||||||
@@ -85,22 +86,22 @@ See the [Run Examples](#run-examples) section below to try out other examples.
|
|||||||
Remix the [glitch starter template](https://glitch.com/edit/#!/forge-dev)
|
Remix the [glitch starter template](https://glitch.com/edit/#!/forge-dev)
|
||||||
|
|
||||||
### Usage from CDN
|
### Usage from CDN
|
||||||
TO-DO: setup CDN
|
|
||||||
```html
|
```html
|
||||||
<script type="importmap">
|
<script type="importmap">
|
||||||
{
|
{
|
||||||
"imports": {
|
"imports": {
|
||||||
"three": "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.174.0/three.module.js",
|
"three": "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.174.0/three.module.js",
|
||||||
"forge": "cdn/url/to/forge.module.js"
|
"forge": "https://forge.dev/releases/forge/0.1.0/forge.module.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install with NPM
|
### Install with NPM
|
||||||
TO-DO: publish package
|
|
||||||
```shell
|
```shell
|
||||||
npm install forge-dev
|
npm install @forge-dev/forge
|
||||||
```
|
```
|
||||||
|
|
||||||
## Run Examples
|
## Run Examples
|
||||||
|
|||||||
Reference in New Issue
Block a user