-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #725 from zeux/jsformat
Integrate Prettier for all JS source
- Loading branch information
Showing
21 changed files
with
977 additions
and
893 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"useTabs": true, | ||
"tabWidth": 4, | ||
"semi": true, | ||
"singleQuote": true, | ||
"printWidth": 150, | ||
} |
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 |
---|---|---|
@@ -1,66 +1,67 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
|
||
<title>meshoptimizer - demo</title> | ||
<title>meshoptimizer - demo</title> | ||
|
||
<script src="https://preview.babylonjs.com/babylon.js"></script> | ||
<script src="https://preview.babylonjs.com/loaders/babylon.glTF2FileLoader.js"></script> | ||
<script src="https://preview.babylonjs.com/babylon.js"></script> | ||
<script src="https://preview.babylonjs.com/loaders/babylon.glTF2FileLoader.js"></script> | ||
|
||
<style> | ||
html, body { | ||
overflow: hidden; | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
<style> | ||
html, | ||
body { | ||
overflow: hidden; | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#renderCanvas { | ||
width: 100%; | ||
height: 100%; | ||
touch-action: none; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<canvas id="renderCanvas"></canvas> | ||
<script> | ||
// Optional - by default Babylon.JS will use bundled decoder module | ||
BABYLON.GLTF2.Loader.Extensions.EXT_meshopt_compression.DecoderPath = '../js/meshopt_decoder.module.js'; | ||
#renderCanvas { | ||
width: 100%; | ||
height: 100%; | ||
touch-action: none; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<canvas id="renderCanvas"></canvas> | ||
<script> | ||
// Optional - by default Babylon.JS will use bundled decoder module | ||
BABYLON.GLTF2.Loader.Extensions.EXT_meshopt_compression.DecoderPath = '../js/meshopt_decoder.module.js'; | ||
|
||
var canvas = document.getElementById("renderCanvas"); | ||
var canvas = document.getElementById('renderCanvas'); | ||
|
||
var createScene = function () { | ||
var scene = new BABYLON.Scene(engine); | ||
var createScene = function () { | ||
var scene = new BABYLON.Scene(engine); | ||
|
||
var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 10, BABYLON.Vector3.Zero(), scene); | ||
camera.attachControl(canvas, false); | ||
var camera = new BABYLON.ArcRotateCamera('Camera', 0, 0.8, 10, BABYLON.Vector3.Zero(), scene); | ||
camera.attachControl(canvas, false); | ||
|
||
BABYLON.SceneLoader.Append("", "pirate.glb", scene, function (newMeshes) { | ||
scene.activeCamera = null; | ||
scene.createDefaultCameraOrLight(true); | ||
scene.activeCamera.attachControl(canvas, false); | ||
scene.activeCamera.alpha = Math.PI / 2; | ||
}); | ||
BABYLON.SceneLoader.Append('', 'pirate.glb', scene, function (newMeshes) { | ||
scene.activeCamera = null; | ||
scene.createDefaultCameraOrLight(true); | ||
scene.activeCamera.attachControl(canvas, false); | ||
scene.activeCamera.alpha = Math.PI / 2; | ||
}); | ||
|
||
return scene; | ||
} | ||
return scene; | ||
}; | ||
|
||
var engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true }); | ||
var scene = createScene(); | ||
var engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true }); | ||
var scene = createScene(); | ||
|
||
engine.runRenderLoop(function () { | ||
if (scene) { | ||
scene.render(); | ||
} | ||
}); | ||
engine.runRenderLoop(function () { | ||
if (scene) { | ||
scene.render(); | ||
} | ||
}); | ||
|
||
// Resize | ||
window.addEventListener("resize", function () { | ||
engine.resize(); | ||
}); | ||
</script> | ||
</body> | ||
// Resize | ||
window.addEventListener('resize', function () { | ||
engine.resize(); | ||
}); | ||
</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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>meshoptimizer - demo</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" /> | ||
<style> | ||
body { | ||
font-family: Monospace; | ||
|
@@ -19,9 +19,15 @@ | |
width: 100%; | ||
text-align: center; | ||
z-index: 100; | ||
display:block; | ||
display: block; | ||
} | ||
#info a, | ||
.button { | ||
color: #f00; | ||
font-weight: bold; | ||
text-decoration: underline; | ||
cursor: pointer; | ||
} | ||
#info a, .button { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer } | ||
</style> | ||
|
||
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script> | ||
|
@@ -37,7 +43,7 @@ | |
|
||
<body> | ||
<div id="info"> | ||
<a href="https://github.com/zeux/meshoptimizer" target="_blank" rel="noopener">meshoptimizer</a> | ||
<a href="https://github.com/zeux/meshoptimizer" target="_blank" rel="noopener">meshoptimizer</a> | ||
</div> | ||
|
||
<script type="module"> | ||
|
@@ -55,8 +61,7 @@ | |
init(); | ||
animate(); | ||
|
||
function init() | ||
{ | ||
function init() { | ||
container = document.createElement('div'); | ||
document.body.appendChild(container); | ||
|
||
|
@@ -82,21 +87,26 @@ | |
|
||
var loader = new GLTFLoader(); | ||
loader.setMeshoptDecoder(MeshoptDecoder); | ||
loader.load('pirate.glb', function (gltf) { | ||
var bbox = new THREE.Box3().setFromObject(gltf.scene); | ||
var scale = 2 / (bbox.max.y - bbox.min.y); | ||
loader.load( | ||
'pirate.glb', | ||
function (gltf) { | ||
var bbox = new THREE.Box3().setFromObject(gltf.scene); | ||
var scale = 2 / (bbox.max.y - bbox.min.y); | ||
|
||
gltf.scene.scale.set(scale, scale, scale); | ||
gltf.scene.position.set(0, 0, 0); | ||
gltf.scene.scale.set(scale, scale, scale); | ||
gltf.scene.position.set(0, 0, 0); | ||
|
||
scene.add(gltf.scene); | ||
scene.add(gltf.scene); | ||
|
||
mixer = new THREE.AnimationMixer(gltf.scene); | ||
mixer = new THREE.AnimationMixer(gltf.scene); | ||
|
||
if (gltf.animations.length) { | ||
mixer.clipAction(gltf.animations[gltf.animations.length - 1]).play(); | ||
} | ||
}, onProgress, onError); | ||
if (gltf.animations.length) { | ||
mixer.clipAction(gltf.animations[gltf.animations.length - 1]).play(); | ||
} | ||
}, | ||
onProgress, | ||
onError, | ||
); | ||
|
||
renderer = new THREE.WebGLRenderer(); | ||
renderer.setPixelRatio(window.devicePixelRatio); | ||
|
@@ -108,8 +118,7 @@ | |
clock = new THREE.Clock(); | ||
} | ||
|
||
function onWindowResize() | ||
{ | ||
function onWindowResize() { | ||
windowHalfX = window.innerWidth / 2; | ||
windowHalfY = window.innerHeight / 2; | ||
|
||
|
@@ -119,8 +128,7 @@ | |
renderer.setSize(window.innerWidth, window.innerHeight); | ||
} | ||
|
||
function animate() | ||
{ | ||
function animate() { | ||
if (mixer) { | ||
mixer.update(clock.getDelta()); | ||
} | ||
|
@@ -129,8 +137,7 @@ | |
render(); | ||
} | ||
|
||
function render() | ||
{ | ||
function render() { | ||
renderer.render(scene, camera); | ||
} | ||
</script> | ||
|
Oops, something went wrong.