-
Notifications
You must be signed in to change notification settings - Fork 4
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
Xiaoyu Hou
authored and
Xiaoyu Hou
committed
Feb 24, 2024
1 parent
7b32959
commit 402c4b7
Showing
2 changed files
with
127 additions
and
5 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,15 +1,138 @@ | ||
<!DOCTYPE html> | ||
<!-- <!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Babylon Hugh Hou</title> | ||
<meta charset="UTF-8" /> | ||
<link rel="stylesheet" href="styles.css" /> | ||
<!-- <script src="src/styles.css"></script> --> | ||
</head> | ||
<body> | ||
<canvas id="renderCanvas"></canvas> | ||
<script type="module" src="/index.js"></script> | ||
</body> | ||
</html> --> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
|
||
<title>Babylon.js sample code</title> | ||
|
||
<!-- Babylon.js --> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.6.2/dat.gui.min.js"></script> | ||
<script src="https://assets.babylonjs.com/generated/Assets.js"></script> | ||
<script src="https://cdn.babylonjs.com/recast.js"></script> | ||
<script src="https://cdn.babylonjs.com/ammo.js"></script> | ||
<script src="https://cdn.babylonjs.com/havok/HavokPhysics_umd.js"></script> | ||
<script src="https://cdn.babylonjs.com/cannon.js"></script> | ||
<script src="https://cdn.babylonjs.com/Oimo.js"></script> | ||
<script src="https://cdn.babylonjs.com/earcut.min.js"></script> | ||
<script src="https://cdn.babylonjs.com/babylon.js"></script> | ||
<script src="https://cdn.babylonjs.com/materialsLibrary/babylonjs.materials.min.js"></script> | ||
<script src="https://cdn.babylonjs.com/proceduralTexturesLibrary/babylonjs.proceduralTextures.min.js"></script> | ||
<script src="https://cdn.babylonjs.com/postProcessesLibrary/babylonjs.postProcess.min.js"></script> | ||
<script src="https://cdn.babylonjs.com/loaders/babylonjs.loaders.js"></script> | ||
<script src="https://cdn.babylonjs.com/serializers/babylonjs.serializers.min.js"></script> | ||
<script src="https://cdn.babylonjs.com/gui/babylon.gui.min.js"></script> | ||
<script src="https://cdn.babylonjs.com/inspector/babylon.inspector.bundle.js"></script> | ||
|
||
<style> | ||
html, body { | ||
overflow: hidden; | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#renderCanvas { | ||
width: 100%; | ||
height: 100%; | ||
touch-action: none; | ||
} | ||
|
||
#canvasZone { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="canvasZone"><canvas id="renderCanvas"></canvas></div> | ||
<script> | ||
var canvas = document.getElementById("renderCanvas"); | ||
|
||
var startRenderLoop = function (engine, canvas) { | ||
engine.runRenderLoop(function () { | ||
if (sceneToRender && sceneToRender.activeCamera) { | ||
sceneToRender.render(); | ||
} | ||
}); | ||
} | ||
|
||
// import losAngeles from "./assets/forFacebook-8K-LA.jpg"; | ||
// import athens from "./assets/Athens-8K.jpg"; | ||
// import lakeTahao from "./assets/LakeTahao-10K.jpg"; | ||
// import romeChruch from "./assets/bigchurch.jpg"; | ||
// import athen3d from "./assets/Athen-3D.jpg"; | ||
// import dubai from "./assets/Dubai.jpg"; | ||
// import inTandem from "./assets/in_tandem_3d360.mp4"; | ||
|
||
var athen3d = "./360Viewer3/assets/Athen-3D.jpg"; | ||
var losAngeles = "./360Viewer3/assets/forFacebook-8K-LA.jpg"; | ||
|
||
var engine = null; | ||
var scene = null; | ||
var sceneToRender = null; | ||
var createDefaultEngine = function() { return new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true, disableWebGL2Support: false}); }; | ||
var createScene = function () { | ||
var scene = new BABYLON.Scene(engine); | ||
var camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI / 2, Math.PI / 2, 5, BABYLON.Vector3.Zero(), scene); | ||
camera.attachControl(canvas, true); | ||
camera.inputs.attached.mousewheel.detachControl(canvas); | ||
var vrHelper = scene.createDefaultVRExperience(); | ||
|
||
var dome = new BABYLON.PhotoDome( | ||
"testdome", | ||
athen3d, | ||
{ | ||
resolution: 32, | ||
size: 1000 | ||
}, | ||
scene | ||
); | ||
|
||
dome.imageMode = BABYLON.PhotoDome.MODE_TOPBOTTOM; | ||
|
||
return scene; | ||
}; | ||
window.initFunction = async function() { | ||
|
||
|
||
|
||
var asyncEngineCreation = async function() { | ||
try { | ||
return createDefaultEngine(); | ||
} catch(e) { | ||
console.log("the available createEngine function failed. Creating the default engine instead"); | ||
return createDefaultEngine(); | ||
} | ||
} | ||
|
||
window.engine = await asyncEngineCreation(); | ||
if (!engine) throw 'engine should not be null.'; | ||
startRenderLoop(engine, canvas); | ||
window.scene = createScene();}; | ||
initFunction().then(() => {sceneToRender = scene | ||
}); | ||
|
||
// 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