-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
75 additions
and
46,886 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
node_modules | ||
three | ||
tests/WaterBottle-*.glb | ||
tests/*.bundle.js | ||
tests/**/*.bundle.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
<style> | ||
* { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h3>测试 canvasTexture耗时</h3> | ||
<script src="./index.bundle.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as THREE from '../../build/three.module'; | ||
import { BrowserPlatform } from '../../src/BrowserPlatform/index'; | ||
|
||
THREE.PLATFORM.set(new BrowserPlatform()); | ||
|
||
const renderer = new THREE.WebGL1Renderer({ alpha: true }); | ||
const camera = new THREE.PerspectiveCamera(75, innerWidth / innerHeight, 0.1, 1000); | ||
const scene = new THREE.Scene(); | ||
// const canvas = document.createElement('canvas'); | ||
// const ctx = canvas.getContext('2d'); | ||
// const canvasTexture = new THREE.CanvasTexture(canvas); | ||
|
||
// const geometry = new THREE.BoxGeometry(1, 1, 1); | ||
// const material = new THREE.MeshBasicMaterial({ map: canvasTexture }); | ||
// const box = new THREE.Mesh(geometry, material); | ||
|
||
for (let i = 0; i < 100; i++) { | ||
const canvas = document.createElement('canvas'); | ||
const ctx = canvas.getContext('2d'); | ||
const canvasTexture = new THREE.CanvasTexture(canvas); | ||
|
||
const geometry = new THREE.BoxGeometry(); | ||
const material = new THREE.MeshBasicMaterial({ map: canvasTexture }); | ||
const box = new THREE.Mesh(geometry, material); | ||
|
||
canvas.width = 2 ** 10; | ||
canvas.height = 2 ** 10; | ||
ctx.fillStyle = `rgb(${~~(Math.random() * 255)},${~~(Math.random() * 255)},${~~(Math.random() * 255)})`; | ||
ctx.fillRect(0, 0, 2 ** 9, 2 ** 9); | ||
|
||
box.position.set(Math.random(), Math.random(), -Math.random()); | ||
|
||
scene.add(box); | ||
} | ||
|
||
const render = () => { | ||
requestAnimationFrame(render); | ||
renderer.render(scene, camera); | ||
}; | ||
|
||
document.body.appendChild(renderer.domElement); | ||
|
||
renderer.setSize(innerWidth, innerHeight); | ||
renderer.setPixelRatio(devicePixelRatio); | ||
|
||
camera.position.z = 1; | ||
|
||
render(); |
Oops, something went wrong.