refactoring to three ES6 modules
This commit is contained in:
parent
b11a50c265
commit
dfdeab5809
@ -18,8 +18,6 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -19,8 +19,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -42,7 +40,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.cesiumViewer = new Cesium.Viewer('cesiumContainer', {
|
||||
useDefaultRenderLoop: false,
|
||||
@ -76,7 +76,7 @@
|
||||
|
||||
potreeViewer.setEDLEnabled(true);
|
||||
potreeViewer.setFOV(60);
|
||||
potreeViewer.setPointBudget(3*1000*1000);
|
||||
potreeViewer.setPointBudget(3_000_000);
|
||||
potreeViewer.setBackground(null);
|
||||
|
||||
potreeViewer.setDescription("");
|
||||
@ -99,9 +99,11 @@
|
||||
|
||||
material.size = 1;
|
||||
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
|
||||
scene.view.position.set(675036.45, 3850315.78, 65076.70);
|
||||
scene.view.lookAt(692869.03, 3925774.14, 1581.51);
|
||||
|
||||
potreeViewer.scene.view.setView(
|
||||
[675036.45, 3850315.78, 65076.70],
|
||||
[692869.03, 3925774.14, 1581.51],
|
||||
);
|
||||
|
||||
let pointcloudProjection = e.pointcloud.projection;
|
||||
let mapProjection = proj4.defs("WGS84");
|
||||
@ -247,67 +249,67 @@
|
||||
|
||||
|
||||
function loop(timestamp){
|
||||
requestAnimationFrame(loop);
|
||||
requestAnimationFrame(loop);
|
||||
|
||||
potreeViewer.update(potreeViewer.clock.getDelta(), timestamp);
|
||||
potreeViewer.update(potreeViewer.clock.getDelta(), timestamp);
|
||||
|
||||
potreeViewer.render();
|
||||
potreeViewer.render();
|
||||
|
||||
if(window.toMap !== undefined){
|
||||
if(window.toMap !== undefined){
|
||||
|
||||
{
|
||||
let camera = potreeViewer.scene.getActiveCamera();
|
||||
{
|
||||
let camera = potreeViewer.scene.getActiveCamera();
|
||||
|
||||
let pPos = new THREE.Vector3(0, 0, 0).applyMatrix4(camera.matrixWorld);
|
||||
let pRight = new THREE.Vector3(600, 0, 0).applyMatrix4(camera.matrixWorld);
|
||||
let pUp = new THREE.Vector3(0, 600, 0).applyMatrix4(camera.matrixWorld);
|
||||
let pTarget = potreeViewer.scene.view.getPivot();
|
||||
let pPos = new THREE.Vector3(0, 0, 0).applyMatrix4(camera.matrixWorld);
|
||||
let pRight = new THREE.Vector3(600, 0, 0).applyMatrix4(camera.matrixWorld);
|
||||
let pUp = new THREE.Vector3(0, 600, 0).applyMatrix4(camera.matrixWorld);
|
||||
let pTarget = potreeViewer.scene.view.getPivot();
|
||||
|
||||
let toCes = (pos) => {
|
||||
let xy = [pos.x, pos.y];
|
||||
let height = pos.z;
|
||||
let deg = toMap.forward(xy);
|
||||
let cPos = Cesium.Cartesian3.fromDegrees(...deg, height);
|
||||
let toCes = (pos) => {
|
||||
let xy = [pos.x, pos.y];
|
||||
let height = pos.z;
|
||||
let deg = toMap.forward(xy);
|
||||
let cPos = Cesium.Cartesian3.fromDegrees(...deg, height);
|
||||
|
||||
return cPos;
|
||||
};
|
||||
return cPos;
|
||||
};
|
||||
|
||||
let cPos = toCes(pPos);
|
||||
let cUpTarget = toCes(pUp);
|
||||
let cTarget = toCes(pTarget);
|
||||
let cPos = toCes(pPos);
|
||||
let cUpTarget = toCes(pUp);
|
||||
let cTarget = toCes(pTarget);
|
||||
|
||||
let cDir = Cesium.Cartesian3.subtract(cTarget, cPos, new Cesium.Cartesian3());
|
||||
let cUp = Cesium.Cartesian3.subtract(cUpTarget, cPos, new Cesium.Cartesian3());
|
||||
let cDir = Cesium.Cartesian3.subtract(cTarget, cPos, new Cesium.Cartesian3());
|
||||
let cUp = Cesium.Cartesian3.subtract(cUpTarget, cPos, new Cesium.Cartesian3());
|
||||
|
||||
cDir = Cesium.Cartesian3.normalize(cDir, new Cesium.Cartesian3());
|
||||
cUp = Cesium.Cartesian3.normalize(cUp, new Cesium.Cartesian3());
|
||||
cDir = Cesium.Cartesian3.normalize(cDir, new Cesium.Cartesian3());
|
||||
cUp = Cesium.Cartesian3.normalize(cUp, new Cesium.Cartesian3());
|
||||
|
||||
cesiumViewer.camera.setView({
|
||||
destination : cPos,
|
||||
orientation : {
|
||||
direction : cDir,
|
||||
up : cUp
|
||||
}
|
||||
});
|
||||
cesiumViewer.camera.setView({
|
||||
destination : cPos,
|
||||
orientation : {
|
||||
direction : cDir,
|
||||
up : cUp
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
let aspect = potreeViewer.scene.getActiveCamera().aspect;
|
||||
if(aspect < 1){
|
||||
let fovy = Math.PI * (potreeViewer.scene.getActiveCamera().fov / 180);
|
||||
cesiumViewer.camera.frustum.fov = fovy;
|
||||
}else{
|
||||
let fovy = Math.PI * (potreeViewer.scene.getActiveCamera().fov / 180);
|
||||
let fovx = Math.atan(Math.tan(0.5 * fovy) * aspect) * 2
|
||||
cesiumViewer.camera.frustum.fov = fovx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let aspect = potreeViewer.scene.getActiveCamera().aspect;
|
||||
if(aspect < 1){
|
||||
let fovy = Math.PI * (potreeViewer.scene.getActiveCamera().fov / 180);
|
||||
cesiumViewer.camera.frustum.fov = fovy;
|
||||
}else{
|
||||
let fovy = Math.PI * (potreeViewer.scene.getActiveCamera().fov / 180);
|
||||
let fovx = Math.atan(Math.tan(0.5 * fovy) * aspect) * 2
|
||||
cesiumViewer.camera.frustum.fov = fovx;
|
||||
}
|
||||
|
||||
cesiumViewer.render();
|
||||
}
|
||||
|
||||
cesiumViewer.render();
|
||||
}
|
||||
|
||||
requestAnimationFrame(loop);
|
||||
requestAnimationFrame(loop);
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
// import * as Potree from "../src/Potree.js";
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -36,7 +34,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
@ -66,14 +66,18 @@
|
||||
|
||||
scene.addPointCloud(pointcloud);
|
||||
|
||||
//scene.view.position.set(589974.341, 231698.397, 986.146);
|
||||
//scene.view.lookAt(new THREE.Vector3(589851.587, 231428.213, 715.634));
|
||||
// scene.view.setView(
|
||||
// [589974.341, 231698.397, 986.146],
|
||||
// [589851.587, 231428.213, 715.634],
|
||||
// );
|
||||
viewer.fitToScreen();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
const animation = new Potree.CameraAnimation(viewer);
|
||||
|
||||
@ -104,7 +108,9 @@
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
// viewer.onGUILoaded(() => {
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../build/potree/potree.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/jquery-ui/jquery-ui.min.css">
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../libs/openlayers3/ol.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/spectrum/spectrum.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/jstree/themes/mixed/style.css">
|
||||
@ -20,8 +19,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -45,7 +42,10 @@
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.cesiumViewer = new Cesium.Viewer('cesiumContainer', {
|
||||
useDefaultRenderLoop: false,
|
||||
animation: false,
|
||||
@ -91,14 +91,20 @@
|
||||
});
|
||||
|
||||
Potree.loadPointCloud("http://5.9.65.151/mschuetz/potree/resources/pointclouds/opentopography/CA13_1.4/cloud.js", "CA13", function(e){
|
||||
//Potree.loadPointCloud("../pointclouds/vol_total/cloud.js", "sigeom.sa", e => {
|
||||
potreeViewer.scene.addPointCloud(e.pointcloud);
|
||||
//e.pointcloud.position.z = 0;
|
||||
let material = e.pointcloud.material;
|
||||
|
||||
let pointcloud = e.pointcloud;
|
||||
let scene = potreeViewer.scene;
|
||||
let material = pointcloud.material;
|
||||
|
||||
scene.addPointCloud(pointcloud);
|
||||
|
||||
material.size = 1;
|
||||
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
|
||||
potreeViewer.scene.view.position.set(689429.64, 3877023.77, 42878.97);
|
||||
potreeViewer.scene.view.lookAt(new THREE.Vector3(696072.86, 3916730.04, 82.04));
|
||||
potreeViewer.scene.view.setView(
|
||||
[689429.64, 3877023.77, 42878.97],
|
||||
[696072.86, 3916730.04, 82.04],
|
||||
);
|
||||
|
||||
let pointcloudProjection = e.pointcloud.projection;
|
||||
let mapProjection = proj4.defs("WGS84");
|
||||
@ -117,14 +123,12 @@
|
||||
|
||||
if(window.toMap !== undefined){
|
||||
|
||||
let camera = potreeViewer.scene.getActiveCamera();
|
||||
{
|
||||
let camera = potreeViewer.scene.getActiveCamera();
|
||||
|
||||
if(camera instanceof THREE.PerspectiveCamera){
|
||||
|
||||
|
||||
let pPos = new THREE.Vector3(0, 0, 0).applyMatrix4(camera.matrixWorld);
|
||||
let pRight = new THREE.Vector3(600, 0, 0).applyMatrix4(camera.matrixWorld);
|
||||
let pUp = new THREE.Vector3(0, 600, 0).applyMatrix4(camera.matrixWorld);
|
||||
let pPos = new THREE.Vector3(0, 0, 0).applyMatrix4(camera.matrixWorld);
|
||||
let pRight = new THREE.Vector3(600, 0, 0).applyMatrix4(camera.matrixWorld);
|
||||
let pUp = new THREE.Vector3(0, 600, 0).applyMatrix4(camera.matrixWorld);
|
||||
let pTarget = potreeViewer.scene.view.getPivot();
|
||||
|
||||
let toCes = (pos) => {
|
||||
@ -164,10 +168,9 @@
|
||||
cesiumViewer.camera.frustum.fov = fovx;
|
||||
}
|
||||
|
||||
cesiumViewer.render();
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
cesiumViewer.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -19,8 +19,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -44,7 +42,10 @@
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.cesiumViewer = new Cesium.Viewer('cesiumContainer', {
|
||||
useDefaultRenderLoop: false,
|
||||
animation: false,
|
||||
@ -76,7 +77,7 @@
|
||||
});
|
||||
potreeViewer.setEDLEnabled(true);
|
||||
potreeViewer.setFOV(60);
|
||||
potreeViewer.setPointBudget(4*1000*1000);
|
||||
potreeViewer.setPointBudget(3_000_000);
|
||||
potreeViewer.setMinNodeSize(50);
|
||||
potreeViewer.loadSettingsFromURL();
|
||||
potreeViewer.setBackground(null);
|
||||
@ -100,7 +101,6 @@
|
||||
|
||||
scene.addPointCloud(e.pointcloud);
|
||||
|
||||
|
||||
e.pointcloud.position.set(569277.402752, 5400050.599046, 0);
|
||||
e.pointcloud.rotation.set(0, 0, -0.035);
|
||||
|
||||
|
||||
@ -19,8 +19,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -44,7 +42,9 @@
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
window.cesiumViewer = new Cesium.Viewer('cesiumContainer', {
|
||||
useDefaultRenderLoop: false,
|
||||
animation: false,
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -28,28 +27,23 @@
|
||||
<script src="../libs/jstree/jstree.js"></script>
|
||||
<script src="../build/potree/potree.js"></script>
|
||||
<script src="../libs/plasio/js/laslaz.js"></script>
|
||||
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
|
||||
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
|
||||
<!-- INCLUDE SETTINGS HERE -->
|
||||
|
||||
<div class="potree_container" style="position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; ">
|
||||
<div id="potree_render_area" style="background-image: url('../build/potree/resources/images/background.jpg');">
|
||||
|
||||
<span style="position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); z-index: 10000">
|
||||
|
||||
<input type="button" value="Default Scheme" onclick="setDefaultScheme()"/>
|
||||
<input type="button" value="Tree Scheme" onclick="setTreeScheme()"/>
|
||||
<input type="button" value="Random Scheme" onclick="setRandomScheme()"/>
|
||||
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
@ -68,8 +62,6 @@
|
||||
viewer.toggleSidebar();
|
||||
});
|
||||
|
||||
// Sigeom
|
||||
//Potree.loadPointCloud("../pointclouds/morro_bay_converted/cloud.js", "CA13", function(e){
|
||||
Potree.loadPointCloud("http://5.9.65.151/mschuetz/potree/resources/pointclouds/opentopography/CA13_1.4/cloud.js", "CA13", function(e){
|
||||
viewer.scene.addPointCloud(e.pointcloud);
|
||||
e.pointcloud.position.z = 0;
|
||||
@ -84,25 +76,22 @@
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
function setDefaultScheme(){
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.setDefaultScheme = function(){
|
||||
viewer.setClassifications(Potree.ClassificationScheme.DEFAULT);
|
||||
|
||||
}
|
||||
|
||||
function setTreeScheme(){
|
||||
|
||||
window.setTreeScheme = function(){
|
||||
viewer.setClassifications({
|
||||
5: { visible: true, name: 'trees' , color: [0.0, 1.0, 0.0, 1.0] },
|
||||
DEFAULT: { visible: false, name: 'other' , color: [0.0, 0.0, 0.0, 1.0] },
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function setRandomScheme(){
|
||||
|
||||
window.setRandomScheme = function(){
|
||||
const scheme = {};
|
||||
|
||||
for(let i = 0; i < 32; i++){
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
let clipSpheres = [
|
||||
{position: [0.032, -2.382, 4.279], scale: 3},
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
viewer.setEDLEnabled(true);
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
viewer.setEDLEnabled(true);
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
viewer.setEDLEnabled(true);
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -29,8 +27,6 @@
|
||||
<script src="../libs/jstree/jstree.js"></script>
|
||||
<script src="../build/potree/potree.js"></script>
|
||||
<script src="../libs/plasio/js/laslaz.js"></script>
|
||||
<script src="../libs/other/OBJLoader.js"></script>
|
||||
<script src="../libs/other/PLYLoader.js"></script>
|
||||
|
||||
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
|
||||
<!-- INCLUDE SETTINGS HERE -->
|
||||
@ -40,7 +36,11 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
import {PLYLoader} from "../libs/three.js/loaders/PLYLoader.js";
|
||||
import {OBJLoader} from "../libs/three.js/loaders/OBJLoader.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
@ -272,7 +272,7 @@
|
||||
texture.wrapT = THREE.RepeatWrapping;
|
||||
|
||||
let onError = function ( xhr ) {};
|
||||
let loader = new THREE.OBJLoader( manager );
|
||||
let loader = new OBJLoader( manager );
|
||||
loader.load(`${Potree.resourcePath}/models/stanford_bunny_reduced.obj`, function ( object ) {
|
||||
object.traverse( function ( child ) {
|
||||
if ( child instanceof THREE.Mesh ) {
|
||||
@ -306,7 +306,7 @@
|
||||
}
|
||||
|
||||
// Load untextured bunny from ply
|
||||
var loader = new THREE.PLYLoader();
|
||||
var loader = new PLYLoader();
|
||||
loader.load( Potree.resourcePath + "/models/stanford_bunny_reduced.ply", (geometry) => {
|
||||
geometry.computeVertexNormals();
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -35,7 +33,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -41,7 +39,9 @@
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -41,7 +39,9 @@
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -43,7 +41,9 @@
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
$("#animation_toggle").click( () => {
|
||||
if(!animation.tween){
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,12 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
import {Line2} from "../libs/three.js/lines/Line2.js";
|
||||
import {LineGeometry} from "../libs/three.js/lines/LineGeometry.js";
|
||||
import {LineMaterial} from "../libs/three.js/lines/LineMaterial.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
@ -78,11 +81,11 @@
|
||||
589702.04, 231336.49, 772.91
|
||||
];
|
||||
|
||||
let lineGeometry = new THREE.LineGeometry();
|
||||
let lineGeometry = new LineGeometry();
|
||||
|
||||
lineGeometry.setPositions(path);
|
||||
|
||||
let lineMaterial = new THREE.LineMaterial({
|
||||
let lineMaterial = new LineMaterial({
|
||||
color: 0x00ff00,
|
||||
dashSize: 5,
|
||||
gapSize: 2,
|
||||
@ -95,7 +98,7 @@
|
||||
|
||||
});
|
||||
|
||||
const line = new THREE.Line2(lineGeometry, lineMaterial);
|
||||
const line = new Line2(lineGeometry, lineMaterial);
|
||||
viewer.scene.scene.add(line);
|
||||
}
|
||||
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
|
||||
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +38,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
|
||||
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +38,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
|
||||
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -35,7 +35,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
|
||||
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +38,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
viewer.setEDLEnabled(false);
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
@ -69,7 +69,7 @@
|
||||
let measure = new Potree.Measure();
|
||||
measure.closed = false;
|
||||
measure.addMarker(new THREE.Vector3(589803.18, 231357.35, 745.38));
|
||||
measure.addMarker(new THREE.Vector3(589795.74, 231323.42, 746.21));
|
||||
measure.addMarker(new THREE.Vector3(589795.74, 231323.42, 746.21));
|
||||
measure.addMarker(new THREE.Vector3(589822.50, 231315.90, 744.45));
|
||||
|
||||
scene.addMeasurement(measure);
|
||||
@ -82,7 +82,7 @@
|
||||
measure.showAngles = true;
|
||||
measure.showDistances = false;
|
||||
measure.addMarker(new THREE.Vector3(589866.11, 231372.25, 737.41));
|
||||
measure.addMarker(new THREE.Vector3(589842.15, 231366.82, 743.61));
|
||||
measure.addMarker(new THREE.Vector3(589842.15, 231366.82, 743.61));
|
||||
measure.addMarker(new THREE.Vector3(589860.61, 231348.01, 740.33));
|
||||
|
||||
scene.addMeasurement(measure);
|
||||
@ -106,7 +106,7 @@
|
||||
measure.showDistances = false;
|
||||
measure.showHeight = true;
|
||||
measure.addMarker(new THREE.Vector3(589849.69, 231327.26, 766.32));
|
||||
measure.addMarker(new THREE.Vector3(589840.96, 231329.53, 744.52));
|
||||
measure.addMarker(new THREE.Vector3(589840.96, 231329.53, 744.52));
|
||||
|
||||
scene.addMeasurement(measure);
|
||||
}
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -29,8 +27,6 @@
|
||||
<script src="../libs/jstree/jstree.js"></script>
|
||||
<script src="../build/potree/potree.js"></script>
|
||||
<script src="../libs/plasio/js/laslaz.js"></script>
|
||||
<script src="../libs/other/PLYLoader.js"></script>
|
||||
<script src="../libs/other/OBJLoader.js"></script>
|
||||
|
||||
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
|
||||
<!-- INCLUDE SETTINGS HERE -->
|
||||
@ -40,7 +36,11 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
import {PLYLoader} from "../libs/three.js/loaders/PLYLoader.js";
|
||||
import {OBJLoader} from "../libs/three.js/loaders/OBJLoader.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
@ -72,7 +72,7 @@
|
||||
// viewer.fitToScreen();
|
||||
});
|
||||
|
||||
var loader = new THREE.PLYLoader();
|
||||
var loader = new PLYLoader();
|
||||
loader.load( Potree.resourcePath + "/models/stanford_bunny_reduced.ply", (geometry) => {
|
||||
geometry.computeVertexNormals();
|
||||
|
||||
@ -168,7 +168,7 @@
|
||||
texture.wrapS = THREE.RepeatWrapping;
|
||||
texture.wrapT = THREE.RepeatWrapping;
|
||||
|
||||
let loader = new THREE.OBJLoader( manager );
|
||||
let loader = new OBJLoader( manager );
|
||||
loader.load(`${Potree.resourcePath}/models/stanford_bunny_reduced.obj`, function ( object ) {
|
||||
object.traverse( function ( child ) {
|
||||
if ( child instanceof THREE.Mesh ) {
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
|
||||
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -38,7 +38,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
|
||||
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -35,7 +35,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
@ -79,7 +81,9 @@
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
const cameraParamsPath = "http://5.9.65.151/mschuetz/potree/resources/pointclouds/helimap/epalinges/img_selected/IXM35_190522_nodistortion.xml";
|
||||
const imageParamsPath = "http://5.9.65.151/mschuetz/potree/resources/pointclouds/helimap/epalinges/img_selected/Calib190522_MN95_NF2_cam_estim.txt";
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -42,7 +40,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
|
||||
viewer.setEDLEnabled(false);
|
||||
viewer.setFOV(60);
|
||||
viewer.setPointBudget(3*1000*1000);
|
||||
viewer.setPointBudget(3_000_000);
|
||||
viewer.loadSettingsFromURL();
|
||||
|
||||
viewer.setDescription('San Simeon, CA Central Coast point cloud taken from <a href="http://opentopo.sdsc.edu/gridsphere/gridsphere?cid=geonlidarframeportlet&gs_action=lidarDataset&opentopoID=OTLAS.032013.26910.2" target="_blank">Open Topography</a> (17.7b points)');
|
||||
@ -189,42 +189,6 @@
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
// {
|
||||
// let positions = [
|
||||
// 693738.442, 3916080.340, 175.970,
|
||||
// 694121.015, 3915885.120, 2.500,
|
||||
// 694627.471, 3916099.287, 1.500,
|
||||
// 693961.765, 3916738.056, 1.460,
|
||||
// ];
|
||||
|
||||
// let colors = [
|
||||
// 1, 0, 0,
|
||||
// 1, 0, 0,
|
||||
// 1, 0, 0,
|
||||
// 1, 0, 0,
|
||||
// ];
|
||||
|
||||
// const geometry = new THREE.LineGeometry();
|
||||
// geometry.setPositions( positions );
|
||||
// geometry.setColors( colors );
|
||||
|
||||
// matLine = new THREE.LineMaterial( {
|
||||
// color: 0xff0000,
|
||||
// linewidth: 5, // in pixels
|
||||
// resolution: new THREE.Vector2(2000, 2000),
|
||||
// dashed: false
|
||||
// } );
|
||||
|
||||
// line = new THREE.Line2( geometry, matLine );
|
||||
// line.computeLineDistances();
|
||||
// line.scale.set( 1, 1, 1 );
|
||||
// viewer.scene.scene.add( line );
|
||||
|
||||
// }
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../../libs/three.js/extra/lines.js"></script>
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -38,7 +36,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<script src="../../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../../libs/three.js/build/three.min.js"></script>
|
||||
|
||||
<script src="../../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../../libs/tween/tween.min.js"></script>
|
||||
<script src="../../libs/d3/d3.js"></script>
|
||||
@ -37,7 +37,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
|
||||
@ -49,7 +49,6 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
@ -59,14 +58,8 @@
|
||||
<script src="../libs/jstree/jstree.js"></script>
|
||||
<script src="../build/potree/potree.js"></script>
|
||||
<script src="../libs/plasio/js/laslaz.js"></script>
|
||||
|
||||
<script src='../libs/sql.js/sql-wasm.js'></script>
|
||||
<script src='../libs/geopackage/geopackage.js'></script>
|
||||
<script src="../libs/three.js/extra/lines/LineSegmentsGeometry.js"></script>
|
||||
<script src="../libs/three.js/extra/lines/LineGeometry.js"></script>
|
||||
<script src="../libs/three.js/extra/lines/LineMaterial.js"></script>
|
||||
<script src="../libs/three.js/extra/lines/LineSegments2.js"></script>
|
||||
<script src="../libs/three.js/extra/lines/Line2.js"></script>
|
||||
|
||||
<div class="potree_container" style="position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; ">
|
||||
<div id="potree_render_area">
|
||||
@ -75,7 +68,9 @@
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
@ -116,7 +111,9 @@
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
<script type="module">
|
||||
|
||||
import * as THREE from "../libs/three.js/build/three.module.js";
|
||||
|
||||
// 1: define html of toolbar first
|
||||
// 2: then populate with content and actions
|
||||
@ -297,7 +294,7 @@
|
||||
min: 100 * 1000,
|
||||
max: 1_000_000,
|
||||
step: 100 * 1000,
|
||||
slide: (event, ui) => { this.viewer.setPointBudget(ui.value); }
|
||||
slide: (event, ui) => { viewer.setPointBudget(ui.value); }
|
||||
});
|
||||
|
||||
const onBudgetChange = () => {
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/three.js/extra/lines.js"></script>
|
||||
|
||||
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
|
||||
@ -1,625 +0,0 @@
|
||||
/**
|
||||
* @author qiao / https://github.com/qiao
|
||||
* @author mrdoob / http://mrdoob.com
|
||||
* @author alteredq / http://alteredqualia.com/
|
||||
* @author WestLangley / http://github.com/WestLangley
|
||||
* @author erich666 / http://erichaines.com
|
||||
*/
|
||||
/*global THREE, console */
|
||||
|
||||
// This set of controls performs orbiting, dollying (zooming), and panning. It maintains
|
||||
// the "up" direction as +Y, unlike the TrackballControls. Touch on tablet and phones is
|
||||
// supported.
|
||||
//
|
||||
// Orbit - left mouse / touch: one finger move
|
||||
// Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
|
||||
// Pan - right mouse, or arrow keys / touch: three finter swipe
|
||||
//
|
||||
// This is a drop-in replacement for (most) TrackballControls used in examples.
|
||||
// That is, include this js file and wherever you see:
|
||||
// controls = new THREE.TrackballControls( camera );
|
||||
// controls.target.z = 150;
|
||||
// Simple substitute "OrbitControls" and the control should work as-is.
|
||||
|
||||
THREE.OrbitControls = function ( object, domElement ) {
|
||||
|
||||
this.object = object;
|
||||
this.domElement = ( domElement !== undefined ) ? domElement : document;
|
||||
|
||||
// API
|
||||
|
||||
// Set to false to disable this control
|
||||
this.enabled = true;
|
||||
|
||||
// "target" sets the location of focus, where the control orbits around
|
||||
// and where it pans with respect to.
|
||||
this.target = new THREE.Vector3();
|
||||
|
||||
// center is old, deprecated; use "target" instead
|
||||
this.center = this.target;
|
||||
|
||||
// This option actually enables dollying in and out; left as "zoom" for
|
||||
// backwards compatibility
|
||||
this.noZoom = false;
|
||||
this.zoomSpeed = 1.0;
|
||||
|
||||
// Limits to how far you can dolly in and out
|
||||
this.minDistance = 0;
|
||||
this.maxDistance = Infinity;
|
||||
|
||||
// Set to true to disable this control
|
||||
this.noRotate = false;
|
||||
this.rotateSpeed = 1.0;
|
||||
|
||||
// Set to true to disable this control
|
||||
this.noPan = false;
|
||||
this.keyPanSpeed = 7.0; // pixels moved per arrow key push
|
||||
|
||||
// Set to true to automatically rotate around the target
|
||||
this.autoRotate = false;
|
||||
this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
|
||||
|
||||
// How far you can orbit vertically, upper and lower limits.
|
||||
// Range is 0 to Math.PI radians.
|
||||
this.minPolarAngle = 0; // radians
|
||||
this.maxPolarAngle = Math.PI; // radians
|
||||
|
||||
// Set to true to disable use of the keys
|
||||
this.noKeys = false;
|
||||
|
||||
// The four arrow keys
|
||||
this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
|
||||
|
||||
////////////
|
||||
// internals
|
||||
|
||||
var scope = this;
|
||||
|
||||
var EPS = 0.000001;
|
||||
|
||||
var rotateStart = new THREE.Vector2();
|
||||
var rotateEnd = new THREE.Vector2();
|
||||
var rotateDelta = new THREE.Vector2();
|
||||
|
||||
var panStart = new THREE.Vector2();
|
||||
var panEnd = new THREE.Vector2();
|
||||
var panDelta = new THREE.Vector2();
|
||||
var panOffset = new THREE.Vector3();
|
||||
|
||||
var offset = new THREE.Vector3();
|
||||
|
||||
var dollyStart = new THREE.Vector2();
|
||||
var dollyEnd = new THREE.Vector2();
|
||||
var dollyDelta = new THREE.Vector2();
|
||||
|
||||
var phiDelta = 0;
|
||||
var thetaDelta = 0;
|
||||
var scale = 1;
|
||||
var pan = new THREE.Vector3();
|
||||
|
||||
var lastPosition = new THREE.Vector3();
|
||||
|
||||
var STATE = { NONE : -1, ROTATE : 0, DOLLY : 1, PAN : 2, TOUCH_ROTATE : 3, TOUCH_DOLLY : 4, TOUCH_PAN : 5 };
|
||||
|
||||
var state = STATE.NONE;
|
||||
|
||||
// for reset
|
||||
|
||||
this.target0 = this.target.clone();
|
||||
this.position0 = this.object.position.clone();
|
||||
|
||||
// events
|
||||
|
||||
var changeEvent = { type: 'change' };
|
||||
var startEvent = { type: 'start'};
|
||||
var endEvent = { type: 'end'};
|
||||
|
||||
this.rotateLeft = function ( angle ) {
|
||||
|
||||
if ( angle === undefined ) {
|
||||
|
||||
angle = getAutoRotationAngle();
|
||||
|
||||
}
|
||||
|
||||
thetaDelta -= angle;
|
||||
|
||||
};
|
||||
|
||||
this.rotateUp = function ( angle ) {
|
||||
|
||||
if ( angle === undefined ) {
|
||||
|
||||
angle = getAutoRotationAngle();
|
||||
|
||||
}
|
||||
|
||||
phiDelta -= angle;
|
||||
|
||||
};
|
||||
|
||||
// pass in distance in world space to move left
|
||||
this.panLeft = function ( distance ) {
|
||||
|
||||
var te = this.object.matrix.elements;
|
||||
|
||||
// get X column of matrix
|
||||
panOffset.set( te[ 0 ], te[ 1 ], te[ 2 ] );
|
||||
panOffset.multiplyScalar( - distance );
|
||||
|
||||
pan.add( panOffset );
|
||||
|
||||
};
|
||||
|
||||
// pass in distance in world space to move up
|
||||
this.panUp = function ( distance ) {
|
||||
|
||||
var te = this.object.matrix.elements;
|
||||
|
||||
// get Y column of matrix
|
||||
panOffset.set( te[ 4 ], te[ 5 ], te[ 6 ] );
|
||||
panOffset.multiplyScalar( distance );
|
||||
|
||||
pan.add( panOffset );
|
||||
|
||||
};
|
||||
|
||||
// pass in x,y of change desired in pixel space,
|
||||
// right and down are positive
|
||||
this.pan = function ( deltaX, deltaY ) {
|
||||
|
||||
var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
|
||||
|
||||
if ( scope.object.fov !== undefined ) {
|
||||
|
||||
// perspective
|
||||
var position = scope.object.position;
|
||||
var offset = position.clone().sub( scope.target );
|
||||
var targetDistance = offset.length();
|
||||
|
||||
// half of the fov is center to top of screen
|
||||
targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 );
|
||||
|
||||
// we actually don't use screenWidth, since perspective camera is fixed to screen height
|
||||
scope.panLeft( 2 * deltaX * targetDistance / element.clientHeight );
|
||||
scope.panUp( 2 * deltaY * targetDistance / element.clientHeight );
|
||||
|
||||
} else if ( scope.object.top !== undefined ) {
|
||||
|
||||
// orthographic
|
||||
scope.panLeft( deltaX * (scope.object.right - scope.object.left) / element.clientWidth );
|
||||
scope.panUp( deltaY * (scope.object.top - scope.object.bottom) / element.clientHeight );
|
||||
|
||||
} else {
|
||||
|
||||
// camera neither orthographic or perspective
|
||||
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.dollyIn = function ( dollyScale ) {
|
||||
|
||||
if ( dollyScale === undefined ) {
|
||||
|
||||
dollyScale = getZoomScale();
|
||||
|
||||
}
|
||||
|
||||
scale /= dollyScale;
|
||||
|
||||
};
|
||||
|
||||
this.dollyOut = function ( dollyScale ) {
|
||||
|
||||
if ( dollyScale === undefined ) {
|
||||
|
||||
dollyScale = getZoomScale();
|
||||
|
||||
}
|
||||
|
||||
scale *= dollyScale;
|
||||
|
||||
};
|
||||
|
||||
this.update = function () {
|
||||
|
||||
var position = this.object.position;
|
||||
|
||||
offset.copy( position ).sub( this.target );
|
||||
|
||||
// angle from z-axis around y-axis
|
||||
|
||||
var theta = Math.atan2( offset.x, offset.z );
|
||||
|
||||
// angle from y-axis
|
||||
|
||||
var phi = Math.atan2( Math.sqrt( offset.x * offset.x + offset.z * offset.z ), offset.y );
|
||||
|
||||
if ( this.autoRotate ) {
|
||||
|
||||
this.rotateLeft( getAutoRotationAngle() );
|
||||
|
||||
}
|
||||
|
||||
theta += thetaDelta;
|
||||
phi += phiDelta;
|
||||
|
||||
// restrict phi to be between desired limits
|
||||
phi = Math.max( this.minPolarAngle, Math.min( this.maxPolarAngle, phi ) );
|
||||
|
||||
// restrict phi to be betwee EPS and PI-EPS
|
||||
phi = Math.max( EPS, Math.min( Math.PI - EPS, phi ) );
|
||||
|
||||
var radius = offset.length() * scale;
|
||||
|
||||
// restrict radius to be between desired limits
|
||||
radius = Math.max( this.minDistance, Math.min( this.maxDistance, radius ) );
|
||||
|
||||
// move target to panned location
|
||||
this.target.add( pan );
|
||||
|
||||
offset.x = radius * Math.sin( phi ) * Math.sin( theta );
|
||||
offset.y = radius * Math.cos( phi );
|
||||
offset.z = radius * Math.sin( phi ) * Math.cos( theta );
|
||||
|
||||
position.copy( this.target ).add( offset );
|
||||
|
||||
this.object.lookAt( this.target );
|
||||
|
||||
thetaDelta = 0;
|
||||
phiDelta = 0;
|
||||
scale = 1;
|
||||
pan.set( 0, 0, 0 );
|
||||
|
||||
if ( lastPosition.distanceTo( this.object.position ) > 0 ) {
|
||||
|
||||
this.dispatchEvent( changeEvent );
|
||||
|
||||
lastPosition.copy( this.object.position );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
this.reset = function () {
|
||||
|
||||
state = STATE.NONE;
|
||||
|
||||
this.target.copy( this.target0 );
|
||||
this.object.position.copy( this.position0 );
|
||||
|
||||
this.update();
|
||||
|
||||
};
|
||||
|
||||
function getAutoRotationAngle() {
|
||||
|
||||
return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
|
||||
|
||||
}
|
||||
|
||||
function getZoomScale() {
|
||||
|
||||
return Math.pow( 0.95, scope.zoomSpeed );
|
||||
|
||||
}
|
||||
|
||||
function onMouseDown( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
event.preventDefault();
|
||||
|
||||
if ( event.button === 0 ) {
|
||||
if ( scope.noRotate === true ) return;
|
||||
|
||||
state = STATE.ROTATE;
|
||||
|
||||
rotateStart.set( event.clientX, event.clientY );
|
||||
|
||||
} else if ( event.button === 1 ) {
|
||||
if ( scope.noZoom === true ) return;
|
||||
|
||||
state = STATE.DOLLY;
|
||||
|
||||
dollyStart.set( event.clientX, event.clientY );
|
||||
|
||||
} else if ( event.button === 2 ) {
|
||||
if ( scope.noPan === true ) return;
|
||||
|
||||
state = STATE.PAN;
|
||||
|
||||
panStart.set( event.clientX, event.clientY );
|
||||
|
||||
}
|
||||
|
||||
scope.domElement.addEventListener( 'mousemove', onMouseMove, false );
|
||||
scope.domElement.addEventListener( 'mouseup', onMouseUp, false );
|
||||
scope.dispatchEvent( startEvent );
|
||||
|
||||
}
|
||||
|
||||
function onMouseMove( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
|
||||
|
||||
if ( state === STATE.ROTATE ) {
|
||||
|
||||
if ( scope.noRotate === true ) return;
|
||||
|
||||
rotateEnd.set( event.clientX, event.clientY );
|
||||
rotateDelta.subVectors( rotateEnd, rotateStart );
|
||||
|
||||
// rotating across whole screen goes 360 degrees around
|
||||
scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
|
||||
|
||||
// rotating up and down along whole screen attempts to go 360, but limited to 180
|
||||
scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
|
||||
|
||||
rotateStart.copy( rotateEnd );
|
||||
|
||||
} else if ( state === STATE.DOLLY ) {
|
||||
|
||||
if ( scope.noZoom === true ) return;
|
||||
|
||||
dollyEnd.set( event.clientX, event.clientY );
|
||||
dollyDelta.subVectors( dollyEnd, dollyStart );
|
||||
|
||||
if ( dollyDelta.y > 0 ) {
|
||||
|
||||
scope.dollyIn();
|
||||
|
||||
} else {
|
||||
|
||||
scope.dollyOut();
|
||||
|
||||
}
|
||||
|
||||
dollyStart.copy( dollyEnd );
|
||||
|
||||
} else if ( state === STATE.PAN ) {
|
||||
|
||||
if ( scope.noPan === true ) return;
|
||||
|
||||
panEnd.set( event.clientX, event.clientY );
|
||||
panDelta.subVectors( panEnd, panStart );
|
||||
|
||||
scope.pan( panDelta.x, panDelta.y );
|
||||
|
||||
panStart.copy( panEnd );
|
||||
|
||||
}
|
||||
|
||||
scope.update();
|
||||
|
||||
}
|
||||
|
||||
function onMouseUp( /* event */ ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
scope.domElement.removeEventListener( 'mousemove', onMouseMove, false );
|
||||
scope.domElement.removeEventListener( 'mouseup', onMouseUp, false );
|
||||
scope.dispatchEvent( endEvent );
|
||||
state = STATE.NONE;
|
||||
|
||||
}
|
||||
|
||||
function onMouseWheel( event ) {
|
||||
|
||||
if ( scope.enabled === false || scope.noZoom === true ) return;
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var delta = 0;
|
||||
|
||||
if ( event.wheelDelta !== undefined ) { // WebKit / Opera / Explorer 9
|
||||
|
||||
delta = event.wheelDelta;
|
||||
|
||||
} else if ( event.detail !== undefined ) { // Firefox
|
||||
|
||||
delta = - event.detail;
|
||||
|
||||
}
|
||||
|
||||
if ( delta > 0 ) {
|
||||
|
||||
scope.dollyOut();
|
||||
|
||||
} else {
|
||||
|
||||
scope.dollyIn();
|
||||
|
||||
}
|
||||
|
||||
scope.update();
|
||||
scope.dispatchEvent( startEvent );
|
||||
scope.dispatchEvent( endEvent );
|
||||
|
||||
}
|
||||
|
||||
function onKeyDown( event ) {
|
||||
|
||||
if ( scope.enabled === false || scope.noKeys === true || scope.noPan === true ) return;
|
||||
|
||||
switch ( event.keyCode ) {
|
||||
|
||||
case scope.keys.UP:
|
||||
scope.pan( 0, scope.keyPanSpeed );
|
||||
scope.update();
|
||||
break;
|
||||
|
||||
case scope.keys.BOTTOM:
|
||||
scope.pan( 0, - scope.keyPanSpeed );
|
||||
scope.update();
|
||||
break;
|
||||
|
||||
case scope.keys.LEFT:
|
||||
scope.pan( scope.keyPanSpeed, 0 );
|
||||
scope.update();
|
||||
break;
|
||||
|
||||
case scope.keys.RIGHT:
|
||||
scope.pan( - scope.keyPanSpeed, 0 );
|
||||
scope.update();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function touchstart( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
switch ( event.touches.length ) {
|
||||
|
||||
case 1: // one-fingered touch: rotate
|
||||
|
||||
if ( scope.noRotate === true ) return;
|
||||
|
||||
state = STATE.TOUCH_ROTATE;
|
||||
|
||||
rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
||||
break;
|
||||
|
||||
case 2: // two-fingered touch: dolly
|
||||
|
||||
if ( scope.noZoom === true ) return;
|
||||
|
||||
state = STATE.TOUCH_DOLLY;
|
||||
|
||||
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
||||
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
||||
var distance = Math.sqrt( dx * dx + dy * dy );
|
||||
dollyStart.set( 0, distance );
|
||||
break;
|
||||
|
||||
case 3: // three-fingered touch: pan
|
||||
|
||||
if ( scope.noPan === true ) return;
|
||||
|
||||
state = STATE.TOUCH_PAN;
|
||||
|
||||
panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
state = STATE.NONE;
|
||||
|
||||
}
|
||||
|
||||
scope.dispatchEvent( startEvent );
|
||||
|
||||
}
|
||||
|
||||
function touchmove( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
|
||||
|
||||
switch ( event.touches.length ) {
|
||||
|
||||
case 1: // one-fingered touch: rotate
|
||||
|
||||
if ( scope.noRotate === true ) return;
|
||||
if ( state !== STATE.TOUCH_ROTATE ) return;
|
||||
|
||||
rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
||||
rotateDelta.subVectors( rotateEnd, rotateStart );
|
||||
|
||||
// rotating across whole screen goes 360 degrees around
|
||||
scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
|
||||
// rotating up and down along whole screen attempts to go 360, but limited to 180
|
||||
scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
|
||||
|
||||
rotateStart.copy( rotateEnd );
|
||||
|
||||
scope.update();
|
||||
break;
|
||||
|
||||
case 2: // two-fingered touch: dolly
|
||||
|
||||
if ( scope.noZoom === true ) return;
|
||||
if ( state !== STATE.TOUCH_DOLLY ) return;
|
||||
|
||||
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
||||
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
||||
var distance = Math.sqrt( dx * dx + dy * dy );
|
||||
|
||||
dollyEnd.set( 0, distance );
|
||||
dollyDelta.subVectors( dollyEnd, dollyStart );
|
||||
|
||||
if ( dollyDelta.y > 0 ) {
|
||||
|
||||
scope.dollyOut();
|
||||
|
||||
} else {
|
||||
|
||||
scope.dollyIn();
|
||||
|
||||
}
|
||||
|
||||
dollyStart.copy( dollyEnd );
|
||||
|
||||
scope.update();
|
||||
break;
|
||||
|
||||
case 3: // three-fingered touch: pan
|
||||
|
||||
if ( scope.noPan === true ) return;
|
||||
if ( state !== STATE.TOUCH_PAN ) return;
|
||||
|
||||
panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
||||
panDelta.subVectors( panEnd, panStart );
|
||||
|
||||
scope.pan( panDelta.x, panDelta.y );
|
||||
|
||||
panStart.copy( panEnd );
|
||||
|
||||
scope.update();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
state = STATE.NONE;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function touchend( /* event */ ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
scope.dispatchEvent( endEvent );
|
||||
state = STATE.NONE;
|
||||
|
||||
}
|
||||
|
||||
this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
|
||||
this.domElement.addEventListener( 'mousedown', onMouseDown, false );
|
||||
this.domElement.addEventListener( 'mousewheel', onMouseWheel, false );
|
||||
this.domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox
|
||||
|
||||
this.domElement.addEventListener( 'touchstart', touchstart, false );
|
||||
this.domElement.addEventListener( 'touchend', touchend, false );
|
||||
this.domElement.addEventListener( 'touchmove', touchmove, false );
|
||||
|
||||
window.addEventListener( 'keydown', onKeyDown, false );
|
||||
|
||||
};
|
||||
|
||||
THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );
|
||||
3939
libs/three.js/extra/GLTFLoader.js
Normal file
3939
libs/three.js/extra/GLTFLoader.js
Normal file
File diff suppressed because it is too large
Load Diff
311
libs/three.js/extra/XRControllerModelFactory.js
Normal file
311
libs/three.js/extra/XRControllerModelFactory.js
Normal file
@ -0,0 +1,311 @@
|
||||
import {
|
||||
Mesh,
|
||||
MeshBasicMaterial,
|
||||
Object3D,
|
||||
Quaternion,
|
||||
SphereBufferGeometry,
|
||||
} from '../build/three.module.js';
|
||||
|
||||
import { GLTFLoader } from '../loaders/GLTFLoader.js';
|
||||
|
||||
import {
|
||||
Constants as MotionControllerConstants,
|
||||
fetchProfile,
|
||||
MotionController
|
||||
} from '../libs/motion-controllers.module.js';
|
||||
|
||||
const DEFAULT_PROFILES_PATH = 'https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles';
|
||||
const DEFAULT_PROFILE = 'generic-trigger';
|
||||
|
||||
function XRControllerModel( ) {
|
||||
|
||||
Object3D.call( this );
|
||||
|
||||
this.motionController = null;
|
||||
this.envMap = null;
|
||||
|
||||
}
|
||||
|
||||
XRControllerModel.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
||||
|
||||
constructor: XRControllerModel,
|
||||
|
||||
setEnvironmentMap: function ( envMap ) {
|
||||
|
||||
if ( this.envMap == envMap ) {
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
this.envMap = envMap;
|
||||
this.traverse( ( child ) => {
|
||||
|
||||
if ( child.isMesh ) {
|
||||
|
||||
child.material.envMap = this.envMap;
|
||||
child.material.needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Polls data from the XRInputSource and updates the model's components to match
|
||||
* the real world data
|
||||
*/
|
||||
updateMatrixWorld: function ( force ) {
|
||||
|
||||
Object3D.prototype.updateMatrixWorld.call( this, force );
|
||||
|
||||
if ( ! this.motionController ) return;
|
||||
|
||||
// Cause the MotionController to poll the Gamepad for data
|
||||
this.motionController.updateFromGamepad();
|
||||
|
||||
// Update the 3D model to reflect the button, thumbstick, and touchpad state
|
||||
Object.values( this.motionController.components ).forEach( ( component ) => {
|
||||
|
||||
// Update node data based on the visual responses' current states
|
||||
Object.values( component.visualResponses ).forEach( ( visualResponse ) => {
|
||||
|
||||
const { valueNode, minNode, maxNode, value, valueNodeProperty } = visualResponse;
|
||||
|
||||
// Skip if the visual response node is not found. No error is needed,
|
||||
// because it will have been reported at load time.
|
||||
if ( ! valueNode ) return;
|
||||
|
||||
// Calculate the new properties based on the weight supplied
|
||||
if ( valueNodeProperty === MotionControllerConstants.VisualResponseProperty.VISIBILITY ) {
|
||||
|
||||
valueNode.visible = value;
|
||||
|
||||
} else if ( valueNodeProperty === MotionControllerConstants.VisualResponseProperty.TRANSFORM ) {
|
||||
|
||||
Quaternion.slerp(
|
||||
minNode.quaternion,
|
||||
maxNode.quaternion,
|
||||
valueNode.quaternion,
|
||||
value
|
||||
);
|
||||
|
||||
valueNode.position.lerpVectors(
|
||||
minNode.position,
|
||||
maxNode.position,
|
||||
value
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
/**
|
||||
* Walks the model's tree to find the nodes needed to animate the components and
|
||||
* saves them to the motionContoller components for use in the frame loop. When
|
||||
* touchpads are found, attaches a touch dot to them.
|
||||
*/
|
||||
function findNodes( motionController, scene ) {
|
||||
|
||||
// Loop through the components and find the nodes needed for each components' visual responses
|
||||
Object.values( motionController.components ).forEach( ( component ) => {
|
||||
|
||||
const { type, touchPointNodeName, visualResponses } = component;
|
||||
|
||||
if ( type === MotionControllerConstants.ComponentType.TOUCHPAD ) {
|
||||
|
||||
component.touchPointNode = scene.getObjectByName( touchPointNodeName );
|
||||
if ( component.touchPointNode ) {
|
||||
|
||||
// Attach a touch dot to the touchpad.
|
||||
const sphereGeometry = new SphereBufferGeometry( 0.001 );
|
||||
const material = new MeshBasicMaterial( { color: 0x0000FF } );
|
||||
const sphere = new Mesh( sphereGeometry, material );
|
||||
component.touchPointNode.add( sphere );
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( `Could not find touch dot, ${component.touchPointNodeName}, in touchpad component ${component.id}` );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Loop through all the visual responses to be applied to this component
|
||||
Object.values( visualResponses ).forEach( ( visualResponse ) => {
|
||||
|
||||
const { valueNodeName, minNodeName, maxNodeName, valueNodeProperty } = visualResponse;
|
||||
|
||||
// If animating a transform, find the two nodes to be interpolated between.
|
||||
if ( valueNodeProperty === MotionControllerConstants.VisualResponseProperty.TRANSFORM ) {
|
||||
|
||||
visualResponse.minNode = scene.getObjectByName( minNodeName );
|
||||
visualResponse.maxNode = scene.getObjectByName( maxNodeName );
|
||||
|
||||
// If the extents cannot be found, skip this animation
|
||||
if ( ! visualResponse.minNode ) {
|
||||
|
||||
console.warn( `Could not find ${minNodeName} in the model` );
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if ( ! visualResponse.maxNode ) {
|
||||
|
||||
console.warn( `Could not find ${maxNodeName} in the model` );
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If the target node cannot be found, skip this animation
|
||||
visualResponse.valueNode = scene.getObjectByName( valueNodeName );
|
||||
if ( ! visualResponse.valueNode ) {
|
||||
|
||||
console.warn( `Could not find ${valueNodeName} in the model` );
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
function addAssetSceneToControllerModel( controllerModel, scene ) {
|
||||
|
||||
// Find the nodes needed for animation and cache them on the motionController.
|
||||
findNodes( controllerModel.motionController, scene );
|
||||
|
||||
// Apply any environment map that the mesh already has set.
|
||||
if ( controllerModel.envMap ) {
|
||||
|
||||
scene.traverse( ( child ) => {
|
||||
|
||||
if ( child.isMesh ) {
|
||||
|
||||
child.material.envMap = controllerModel.envMap;
|
||||
child.material.needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
// Add the glTF scene to the controllerModel.
|
||||
controllerModel.add( scene );
|
||||
|
||||
}
|
||||
|
||||
var XRControllerModelFactory = ( function () {
|
||||
|
||||
function XRControllerModelFactory( gltfLoader = null ) {
|
||||
|
||||
this.gltfLoader = gltfLoader;
|
||||
this.path = DEFAULT_PROFILES_PATH;
|
||||
this._assetCache = {};
|
||||
|
||||
// If a GLTFLoader wasn't supplied to the constructor create a new one.
|
||||
if ( ! this.gltfLoader ) {
|
||||
|
||||
this.gltfLoader = new GLTFLoader();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
XRControllerModelFactory.prototype = {
|
||||
|
||||
constructor: XRControllerModelFactory,
|
||||
|
||||
createControllerModel: function ( controller ) {
|
||||
|
||||
const controllerModel = new XRControllerModel();
|
||||
let scene = null;
|
||||
|
||||
controller.addEventListener( 'connected', ( event ) => {
|
||||
|
||||
const xrInputSource = event.data;
|
||||
|
||||
if ( xrInputSource.targetRayMode !== 'tracked-pointer' || ! xrInputSource.gamepad ) return;
|
||||
|
||||
fetchProfile( xrInputSource, this.path, DEFAULT_PROFILE ).then( ( { profile, assetPath } ) => {
|
||||
|
||||
controllerModel.motionController = new MotionController(
|
||||
xrInputSource,
|
||||
profile,
|
||||
assetPath
|
||||
);
|
||||
|
||||
const cachedAsset = this._assetCache[ controllerModel.motionController.assetUrl ];
|
||||
if ( cachedAsset ) {
|
||||
|
||||
scene = cachedAsset.scene.clone();
|
||||
|
||||
addAssetSceneToControllerModel( controllerModel, scene );
|
||||
|
||||
} else {
|
||||
|
||||
if ( ! this.gltfLoader ) {
|
||||
|
||||
throw new Error( 'GLTFLoader not set.' );
|
||||
|
||||
}
|
||||
|
||||
this.gltfLoader.setPath( '' );
|
||||
this.gltfLoader.load( controllerModel.motionController.assetUrl, ( asset ) => {
|
||||
|
||||
this._assetCache[ controllerModel.motionController.assetUrl ] = asset;
|
||||
|
||||
scene = asset.scene.clone();
|
||||
|
||||
addAssetSceneToControllerModel( controllerModel, scene );
|
||||
|
||||
},
|
||||
null,
|
||||
() => {
|
||||
|
||||
throw new Error( `Asset ${controllerModel.motionController.assetUrl} missing or malformed.` );
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
} ).catch( ( err ) => {
|
||||
|
||||
console.warn( err );
|
||||
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
controller.addEventListener( 'disconnected', () => {
|
||||
|
||||
controllerModel.motionController = null;
|
||||
controllerModel.remove( scene );
|
||||
scene = null;
|
||||
|
||||
} );
|
||||
|
||||
return controllerModel;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return XRControllerModelFactory;
|
||||
|
||||
} )();
|
||||
|
||||
export { XRControllerModelFactory };
|
||||
3
libs/three.js/libs/chevrotain.module.min.js
vendored
Normal file
3
libs/three.js/libs/chevrotain.module.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3575
libs/three.js/libs/dat.gui.module.js
Normal file
3575
libs/three.js/libs/dat.gui.module.js
Normal file
File diff suppressed because one or more lines are too long
27
libs/three.js/libs/deflate.module.min.js
vendored
Normal file
27
libs/three.js/libs/deflate.module.min.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */ var mod={},n=void 0,w=!0,aa=mod; function ba(f,d){var c=f.split("."),e=aa;!(c[0]in e)&&e.execScript&&e.execScript("var "+c[0]);for(var b;c.length&&(b=c.shift());)!c.length&&d!==n?e[b]=d:e=e[b]?e[b]:e[b]={}};var C="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array&&"undefined"!==typeof DataView;function K(f,d){this.index="number"===typeof d?d:0;this.e=0;this.buffer=f instanceof(C?Uint8Array:Array)?f:new (C?Uint8Array:Array)(32768);if(2*this.buffer.length<=this.index)throw Error("invalid index");this.buffer.length<=this.index&&ca(this)}function ca(f){var d=f.buffer,c,e=d.length,b=new (C?Uint8Array:Array)(e<<1);if(C)b.set(d);else for(c=0;c<e;++c)b[c]=d[c];return f.buffer=b}
|
||||
K.prototype.b=function(f,d,c){var e=this.buffer,b=this.index,a=this.e,g=e[b],m;c&&1<d&&(f=8<d?(L[f&255]<<24|L[f>>>8&255]<<16|L[f>>>16&255]<<8|L[f>>>24&255])>>32-d:L[f]>>8-d);if(8>d+a)g=g<<d|f,a+=d;else for(m=0;m<d;++m)g=g<<1|f>>d-m-1&1,8===++a&&(a=0,e[b++]=L[g],g=0,b===e.length&&(e=ca(this)));e[b]=g;this.buffer=e;this.e=a;this.index=b};K.prototype.finish=function(){var f=this.buffer,d=this.index,c;0<this.e&&(f[d]<<=8-this.e,f[d]=L[f[d]],d++);C?c=f.subarray(0,d):(f.length=d,c=f);return c};
|
||||
var da=new (C?Uint8Array:Array)(256),M;for(M=0;256>M;++M){for(var N=M,S=N,ea=7,N=N>>>1;N;N>>>=1)S<<=1,S|=N&1,--ea;da[M]=(S<<ea&255)>>>0}var L=da;function ia(f){this.buffer=new (C?Uint16Array:Array)(2*f);this.length=0}ia.prototype.getParent=function(f){return 2*((f-2)/4|0)};ia.prototype.push=function(f,d){var c,e,b=this.buffer,a;c=this.length;b[this.length++]=d;for(b[this.length++]=f;0<c;)if(e=this.getParent(c),b[c]>b[e])a=b[c],b[c]=b[e],b[e]=a,a=b[c+1],b[c+1]=b[e+1],b[e+1]=a,c=e;else break;return this.length};
|
||||
ia.prototype.pop=function(){var f,d,c=this.buffer,e,b,a;d=c[0];f=c[1];this.length-=2;c[0]=c[this.length];c[1]=c[this.length+1];for(a=0;;){b=2*a+2;if(b>=this.length)break;b+2<this.length&&c[b+2]>c[b]&&(b+=2);if(c[b]>c[a])e=c[a],c[a]=c[b],c[b]=e,e=c[a+1],c[a+1]=c[b+1],c[b+1]=e;else break;a=b}return{index:f,value:d,length:this.length}};function ka(f,d){this.d=la;this.i=0;this.input=C&&f instanceof Array?new Uint8Array(f):f;this.c=0;d&&(d.lazy&&(this.i=d.lazy),"number"===typeof d.compressionType&&(this.d=d.compressionType),d.outputBuffer&&(this.a=C&&d.outputBuffer instanceof Array?new Uint8Array(d.outputBuffer):d.outputBuffer),"number"===typeof d.outputIndex&&(this.c=d.outputIndex));this.a||(this.a=new (C?Uint8Array:Array)(32768))}var la=2,na={NONE:0,h:1,g:la,n:3},T=[],U;
|
||||
for(U=0;288>U;U++)switch(w){case 143>=U:T.push([U+48,8]);break;case 255>=U:T.push([U-144+400,9]);break;case 279>=U:T.push([U-256+0,7]);break;case 287>=U:T.push([U-280+192,8]);break;default:throw"invalid literal: "+U;}
|
||||
ka.prototype.f=function(){var f,d,c,e,b=this.input;switch(this.d){case 0:c=0;for(e=b.length;c<e;){d=C?b.subarray(c,c+65535):b.slice(c,c+65535);c+=d.length;var a=d,g=c===e,m=n,k=n,p=n,t=n,u=n,l=this.a,h=this.c;if(C){for(l=new Uint8Array(this.a.buffer);l.length<=h+a.length+5;)l=new Uint8Array(l.length<<1);l.set(this.a)}m=g?1:0;l[h++]=m|0;k=a.length;p=~k+65536&65535;l[h++]=k&255;l[h++]=k>>>8&255;l[h++]=p&255;l[h++]=p>>>8&255;if(C)l.set(a,h),h+=a.length,l=l.subarray(0,h);else{t=0;for(u=a.length;t<u;++t)l[h++]=
|
||||
a[t];l.length=h}this.c=h;this.a=l}break;case 1:var q=new K(C?new Uint8Array(this.a.buffer):this.a,this.c);q.b(1,1,w);q.b(1,2,w);var s=oa(this,b),x,fa,z;x=0;for(fa=s.length;x<fa;x++)if(z=s[x],K.prototype.b.apply(q,T[z]),256<z)q.b(s[++x],s[++x],w),q.b(s[++x],5),q.b(s[++x],s[++x],w);else if(256===z)break;this.a=q.finish();this.c=this.a.length;break;case la:var B=new K(C?new Uint8Array(this.a.buffer):this.a,this.c),ta,J,O,P,Q,La=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],X,ua,Y,va,ga,ja=Array(19),
|
||||
wa,R,ha,y,xa;ta=la;B.b(1,1,w);B.b(ta,2,w);J=oa(this,b);X=pa(this.m,15);ua=qa(X);Y=pa(this.l,7);va=qa(Y);for(O=286;257<O&&0===X[O-1];O--);for(P=30;1<P&&0===Y[P-1];P--);var ya=O,za=P,F=new (C?Uint32Array:Array)(ya+za),r,G,v,Z,E=new (C?Uint32Array:Array)(316),D,A,H=new (C?Uint8Array:Array)(19);for(r=G=0;r<ya;r++)F[G++]=X[r];for(r=0;r<za;r++)F[G++]=Y[r];if(!C){r=0;for(Z=H.length;r<Z;++r)H[r]=0}r=D=0;for(Z=F.length;r<Z;r+=G){for(G=1;r+G<Z&&F[r+G]===F[r];++G);v=G;if(0===F[r])if(3>v)for(;0<v--;)E[D++]=0,
|
||||
H[0]++;else for(;0<v;)A=138>v?v:138,A>v-3&&A<v&&(A=v-3),10>=A?(E[D++]=17,E[D++]=A-3,H[17]++):(E[D++]=18,E[D++]=A-11,H[18]++),v-=A;else if(E[D++]=F[r],H[F[r]]++,v--,3>v)for(;0<v--;)E[D++]=F[r],H[F[r]]++;else for(;0<v;)A=6>v?v:6,A>v-3&&A<v&&(A=v-3),E[D++]=16,E[D++]=A-3,H[16]++,v-=A}f=C?E.subarray(0,D):E.slice(0,D);ga=pa(H,7);for(y=0;19>y;y++)ja[y]=ga[La[y]];for(Q=19;4<Q&&0===ja[Q-1];Q--);wa=qa(ga);B.b(O-257,5,w);B.b(P-1,5,w);B.b(Q-4,4,w);for(y=0;y<Q;y++)B.b(ja[y],3,w);y=0;for(xa=f.length;y<xa;y++)if(R=
|
||||
f[y],B.b(wa[R],ga[R],w),16<=R){y++;switch(R){case 16:ha=2;break;case 17:ha=3;break;case 18:ha=7;break;default:throw"invalid code: "+R;}B.b(f[y],ha,w)}var Aa=[ua,X],Ba=[va,Y],I,Ca,$,ma,Da,Ea,Fa,Ga;Da=Aa[0];Ea=Aa[1];Fa=Ba[0];Ga=Ba[1];I=0;for(Ca=J.length;I<Ca;++I)if($=J[I],B.b(Da[$],Ea[$],w),256<$)B.b(J[++I],J[++I],w),ma=J[++I],B.b(Fa[ma],Ga[ma],w),B.b(J[++I],J[++I],w);else if(256===$)break;this.a=B.finish();this.c=this.a.length;break;default:throw"invalid compression type";}return this.a};
|
||||
function ra(f,d){this.length=f;this.k=d}
|
||||
var sa=function(){function f(b){switch(w){case 3===b:return[257,b-3,0];case 4===b:return[258,b-4,0];case 5===b:return[259,b-5,0];case 6===b:return[260,b-6,0];case 7===b:return[261,b-7,0];case 8===b:return[262,b-8,0];case 9===b:return[263,b-9,0];case 10===b:return[264,b-10,0];case 12>=b:return[265,b-11,1];case 14>=b:return[266,b-13,1];case 16>=b:return[267,b-15,1];case 18>=b:return[268,b-17,1];case 22>=b:return[269,b-19,2];case 26>=b:return[270,b-23,2];case 30>=b:return[271,b-27,2];case 34>=b:return[272,
|
||||
b-31,2];case 42>=b:return[273,b-35,3];case 50>=b:return[274,b-43,3];case 58>=b:return[275,b-51,3];case 66>=b:return[276,b-59,3];case 82>=b:return[277,b-67,4];case 98>=b:return[278,b-83,4];case 114>=b:return[279,b-99,4];case 130>=b:return[280,b-115,4];case 162>=b:return[281,b-131,5];case 194>=b:return[282,b-163,5];case 226>=b:return[283,b-195,5];case 257>=b:return[284,b-227,5];case 258===b:return[285,b-258,0];default:throw"invalid length: "+b;}}var d=[],c,e;for(c=3;258>=c;c++)e=f(c),d[c]=e[2]<<24|
|
||||
e[1]<<16|e[0];return d}(),Ha=C?new Uint32Array(sa):sa;
|
||||
function oa(f,d){function c(b,c){var a=b.k,d=[],e=0,f;f=Ha[b.length];d[e++]=f&65535;d[e++]=f>>16&255;d[e++]=f>>24;var g;switch(w){case 1===a:g=[0,a-1,0];break;case 2===a:g=[1,a-2,0];break;case 3===a:g=[2,a-3,0];break;case 4===a:g=[3,a-4,0];break;case 6>=a:g=[4,a-5,1];break;case 8>=a:g=[5,a-7,1];break;case 12>=a:g=[6,a-9,2];break;case 16>=a:g=[7,a-13,2];break;case 24>=a:g=[8,a-17,3];break;case 32>=a:g=[9,a-25,3];break;case 48>=a:g=[10,a-33,4];break;case 64>=a:g=[11,a-49,4];break;case 96>=a:g=[12,a-
|
||||
65,5];break;case 128>=a:g=[13,a-97,5];break;case 192>=a:g=[14,a-129,6];break;case 256>=a:g=[15,a-193,6];break;case 384>=a:g=[16,a-257,7];break;case 512>=a:g=[17,a-385,7];break;case 768>=a:g=[18,a-513,8];break;case 1024>=a:g=[19,a-769,8];break;case 1536>=a:g=[20,a-1025,9];break;case 2048>=a:g=[21,a-1537,9];break;case 3072>=a:g=[22,a-2049,10];break;case 4096>=a:g=[23,a-3073,10];break;case 6144>=a:g=[24,a-4097,11];break;case 8192>=a:g=[25,a-6145,11];break;case 12288>=a:g=[26,a-8193,12];break;case 16384>=
|
||||
a:g=[27,a-12289,12];break;case 24576>=a:g=[28,a-16385,13];break;case 32768>=a:g=[29,a-24577,13];break;default:throw"invalid distance";}f=g;d[e++]=f[0];d[e++]=f[1];d[e++]=f[2];var k,m;k=0;for(m=d.length;k<m;++k)l[h++]=d[k];s[d[0]]++;x[d[3]]++;q=b.length+c-1;u=null}var e,b,a,g,m,k={},p,t,u,l=C?new Uint16Array(2*d.length):[],h=0,q=0,s=new (C?Uint32Array:Array)(286),x=new (C?Uint32Array:Array)(30),fa=f.i,z;if(!C){for(a=0;285>=a;)s[a++]=0;for(a=0;29>=a;)x[a++]=0}s[256]=1;e=0;for(b=d.length;e<b;++e){a=
|
||||
m=0;for(g=3;a<g&&e+a!==b;++a)m=m<<8|d[e+a];k[m]===n&&(k[m]=[]);p=k[m];if(!(0<q--)){for(;0<p.length&&32768<e-p[0];)p.shift();if(e+3>=b){u&&c(u,-1);a=0;for(g=b-e;a<g;++a)z=d[e+a],l[h++]=z,++s[z];break}0<p.length?(t=Ia(d,e,p),u?u.length<t.length?(z=d[e-1],l[h++]=z,++s[z],c(t,0)):c(u,-1):t.length<fa?u=t:c(t,0)):u?c(u,-1):(z=d[e],l[h++]=z,++s[z])}p.push(e)}l[h++]=256;s[256]++;f.m=s;f.l=x;return C?l.subarray(0,h):l}
|
||||
function Ia(f,d,c){var e,b,a=0,g,m,k,p,t=f.length;m=0;p=c.length;a:for(;m<p;m++){e=c[p-m-1];g=3;if(3<a){for(k=a;3<k;k--)if(f[e+k-1]!==f[d+k-1])continue a;g=a}for(;258>g&&d+g<t&&f[e+g]===f[d+g];)++g;g>a&&(b=e,a=g);if(258===g)break}return new ra(a,d-b)}
|
||||
function pa(f,d){var c=f.length,e=new ia(572),b=new (C?Uint8Array:Array)(c),a,g,m,k,p;if(!C)for(k=0;k<c;k++)b[k]=0;for(k=0;k<c;++k)0<f[k]&&e.push(k,f[k]);a=Array(e.length/2);g=new (C?Uint32Array:Array)(e.length/2);if(1===a.length)return b[e.pop().index]=1,b;k=0;for(p=e.length/2;k<p;++k)a[k]=e.pop(),g[k]=a[k].value;m=Ja(g,g.length,d);k=0;for(p=a.length;k<p;++k)b[a[k].index]=m[k];return b}
|
||||
function Ja(f,d,c){function e(a){var b=k[a][p[a]];b===d?(e(a+1),e(a+1)):--g[b];++p[a]}var b=new (C?Uint16Array:Array)(c),a=new (C?Uint8Array:Array)(c),g=new (C?Uint8Array:Array)(d),m=Array(c),k=Array(c),p=Array(c),t=(1<<c)-d,u=1<<c-1,l,h,q,s,x;b[c-1]=d;for(h=0;h<c;++h)t<u?a[h]=0:(a[h]=1,t-=u),t<<=1,b[c-2-h]=(b[c-1-h]/2|0)+d;b[0]=a[0];m[0]=Array(b[0]);k[0]=Array(b[0]);for(h=1;h<c;++h)b[h]>2*b[h-1]+a[h]&&(b[h]=2*b[h-1]+a[h]),m[h]=Array(b[h]),k[h]=Array(b[h]);for(l=0;l<d;++l)g[l]=c;for(q=0;q<b[c-1];++q)m[c-
|
||||
1][q]=f[q],k[c-1][q]=q;for(l=0;l<c;++l)p[l]=0;1===a[c-1]&&(--g[0],++p[c-1]);for(h=c-2;0<=h;--h){s=l=0;x=p[h+1];for(q=0;q<b[h];q++)s=m[h+1][x]+m[h+1][x+1],s>f[l]?(m[h][q]=s,k[h][q]=d,x+=2):(m[h][q]=f[l],k[h][q]=l,++l);p[h]=0;1===a[h]&&e(h)}return g}
|
||||
function qa(f){var d=new (C?Uint16Array:Array)(f.length),c=[],e=[],b=0,a,g,m,k;a=0;for(g=f.length;a<g;a++)c[f[a]]=(c[f[a]]|0)+1;a=1;for(g=16;a<=g;a++)e[a]=b,b+=c[a]|0,b<<=1;a=0;for(g=f.length;a<g;a++){b=e[f[a]];e[f[a]]+=1;m=d[a]=0;for(k=f[a];m<k;m++)d[a]=d[a]<<1|b&1,b>>>=1}return d};function Ka(f,d){this.input=f;this.a=new (C?Uint8Array:Array)(32768);this.d=V.g;var c={},e;if((d||!(d={}))&&"number"===typeof d.compressionType)this.d=d.compressionType;for(e in d)c[e]=d[e];c.outputBuffer=this.a;this.j=new ka(this.input,c)}var V=na;
|
||||
Ka.prototype.f=function(){var f,d,c,e,b,a,g=0;a=this.a;switch(8){case 8:f=Math.LOG2E*Math.log(32768)-8;break;default:throw Error("invalid compression method");}d=f<<4|8;a[g++]=d;switch(8){case 8:switch(this.d){case V.NONE:e=0;break;case V.h:e=1;break;case V.g:e=2;break;default:throw Error("unsupported compression type");}break;default:throw Error("invalid compression method");}c=e<<6|0;a[g++]=c|31-(256*d+c)%31;var m=this.input;if("string"===typeof m){var k=m.split(""),p,t;p=0;for(t=k.length;p<t;p++)k[p]=
|
||||
(k[p].charCodeAt(0)&255)>>>0;m=k}for(var u=1,l=0,h=m.length,q,s=0;0<h;){q=1024<h?1024:h;h-=q;do u+=m[s++],l+=u;while(--q);u%=65521;l%=65521}b=(l<<16|u)>>>0;this.j.c=g;a=this.j.f();g=a.length;C&&(a=new Uint8Array(a.buffer),a.length<=g+4&&(this.a=new Uint8Array(a.length+4),this.a.set(a),a=this.a),a=a.subarray(0,g+4));a[g++]=b>>24&255;a[g++]=b>>16&255;a[g++]=b>>8&255;a[g++]=b&255;return a};ba("Zlib.Deflate",Ka);ba("Zlib.Deflate.compress",function(f,d){return(new Ka(f,d)).f()});ba("Zlib.Deflate.prototype.compress",Ka.prototype.f);var Ma={NONE:V.NONE,FIXED:V.h,DYNAMIC:V.g},Na,Oa,W,Pa;if(Object.keys)Na=Object.keys(Ma);else for(Oa in Na=[],W=0,Ma)Na[W++]=Oa;W=0;for(Pa=Na.length;W<Pa;++W)Oa=Na[W],ba("Zlib.Deflate.CompressionType."+Oa,Ma[Oa]);
|
||||
var Deflate=mod.Zlib.Deflate;
|
||||
export { Deflate }
|
||||
28
libs/three.js/libs/gunzip.module.min.js
vendored
Normal file
28
libs/three.js/libs/gunzip.module.min.js
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */function n(e){throw e;}var q=void 0,aa={};function r(e,c){var d=e.split("."),b=aa;!(d[0]in b)&&b.execScript&&b.execScript("var "+d[0]);for(var a;d.length&&(a=d.shift());)!d.length&&c!==q?b[a]=c:b=b[a]?b[a]:b[a]={}};var u="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array&&"undefined"!==typeof DataView;new (u?Uint8Array:Array)(256);var v;for(v=0;256>v;++v)for(var w=v,ba=7,w=w>>>1;w;w>>>=1)--ba;function x(e,c,d){var b,a="number"===typeof c?c:c=0,f="number"===typeof d?d:e.length;b=-1;for(a=f&7;a--;++c)b=b>>>8^z[(b^e[c])&255];for(a=f>>3;a--;c+=8)b=b>>>8^z[(b^e[c])&255],b=b>>>8^z[(b^e[c+1])&255],b=b>>>8^z[(b^e[c+2])&255],b=b>>>8^z[(b^e[c+3])&255],b=b>>>8^z[(b^e[c+4])&255],b=b>>>8^z[(b^e[c+5])&255],b=b>>>8^z[(b^e[c+6])&255],b=b>>>8^z[(b^e[c+7])&255];return(b^4294967295)>>>0}
|
||||
var A=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,
|
||||
2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,
|
||||
2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,
|
||||
2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,
|
||||
3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,
|
||||
936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],z=u?new Uint32Array(A):A;function B(){}B.prototype.getName=function(){return this.name};B.prototype.getData=function(){return this.data};B.prototype.H=function(){return this.I};r("Zlib.GunzipMember",B);r("Zlib.GunzipMember.prototype.getName",B.prototype.getName);r("Zlib.GunzipMember.prototype.getData",B.prototype.getData);r("Zlib.GunzipMember.prototype.getMtime",B.prototype.H);function D(e){var c=e.length,d=0,b=Number.POSITIVE_INFINITY,a,f,g,k,m,p,t,h,l,y;for(h=0;h<c;++h)e[h]>d&&(d=e[h]),e[h]<b&&(b=e[h]);a=1<<d;f=new (u?Uint32Array:Array)(a);g=1;k=0;for(m=2;g<=d;){for(h=0;h<c;++h)if(e[h]===g){p=0;t=k;for(l=0;l<g;++l)p=p<<1|t&1,t>>=1;y=g<<16|h;for(l=p;l<a;l+=m)f[l]=y;++k}++g;k<<=1;m<<=1}return[f,d,b]};var E=[],F;for(F=0;288>F;F++)switch(!0){case 143>=F:E.push([F+48,8]);break;case 255>=F:E.push([F-144+400,9]);break;case 279>=F:E.push([F-256+0,7]);break;case 287>=F:E.push([F-280+192,8]);break;default:n("invalid literal: "+F)}
|
||||
var ca=function(){function e(a){switch(!0){case 3===a:return[257,a-3,0];case 4===a:return[258,a-4,0];case 5===a:return[259,a-5,0];case 6===a:return[260,a-6,0];case 7===a:return[261,a-7,0];case 8===a:return[262,a-8,0];case 9===a:return[263,a-9,0];case 10===a:return[264,a-10,0];case 12>=a:return[265,a-11,1];case 14>=a:return[266,a-13,1];case 16>=a:return[267,a-15,1];case 18>=a:return[268,a-17,1];case 22>=a:return[269,a-19,2];case 26>=a:return[270,a-23,2];case 30>=a:return[271,a-27,2];case 34>=a:return[272,
|
||||
a-31,2];case 42>=a:return[273,a-35,3];case 50>=a:return[274,a-43,3];case 58>=a:return[275,a-51,3];case 66>=a:return[276,a-59,3];case 82>=a:return[277,a-67,4];case 98>=a:return[278,a-83,4];case 114>=a:return[279,a-99,4];case 130>=a:return[280,a-115,4];case 162>=a:return[281,a-131,5];case 194>=a:return[282,a-163,5];case 226>=a:return[283,a-195,5];case 257>=a:return[284,a-227,5];case 258===a:return[285,a-258,0];default:n("invalid length: "+a)}}var c=[],d,b;for(d=3;258>=d;d++)b=e(d),c[d]=b[2]<<24|b[1]<<
|
||||
16|b[0];return c}();u&&new Uint32Array(ca);function G(e,c){this.i=[];this.j=32768;this.d=this.f=this.c=this.n=0;this.input=u?new Uint8Array(e):e;this.o=!1;this.k=H;this.z=!1;if(c||!(c={}))c.index&&(this.c=c.index),c.bufferSize&&(this.j=c.bufferSize),c.bufferType&&(this.k=c.bufferType),c.resize&&(this.z=c.resize);switch(this.k){case I:this.a=32768;this.b=new (u?Uint8Array:Array)(32768+this.j+258);break;case H:this.a=0;this.b=new (u?Uint8Array:Array)(this.j);this.e=this.F;this.q=this.B;this.l=this.D;break;default:n(Error("invalid inflate mode"))}}
|
||||
var I=0,H=1;
|
||||
G.prototype.g=function(){for(;!this.o;){var e=J(this,3);e&1&&(this.o=!0);e>>>=1;switch(e){case 0:var c=this.input,d=this.c,b=this.b,a=this.a,f=c.length,g=q,k=q,m=b.length,p=q;this.d=this.f=0;d+1>=f&&n(Error("invalid uncompressed block header: LEN"));g=c[d++]|c[d++]<<8;d+1>=f&&n(Error("invalid uncompressed block header: NLEN"));k=c[d++]|c[d++]<<8;g===~k&&n(Error("invalid uncompressed block header: length verify"));d+g>c.length&&n(Error("input buffer is broken"));switch(this.k){case I:for(;a+g>b.length;){p=
|
||||
m-a;g-=p;if(u)b.set(c.subarray(d,d+p),a),a+=p,d+=p;else for(;p--;)b[a++]=c[d++];this.a=a;b=this.e();a=this.a}break;case H:for(;a+g>b.length;)b=this.e({t:2});break;default:n(Error("invalid inflate mode"))}if(u)b.set(c.subarray(d,d+g),a),a+=g,d+=g;else for(;g--;)b[a++]=c[d++];this.c=d;this.a=a;this.b=b;break;case 1:this.l(da,ea);break;case 2:fa(this);break;default:n(Error("unknown BTYPE: "+e))}}return this.q()};
|
||||
var K=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],L=u?new Uint16Array(K):K,N=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],O=u?new Uint16Array(N):N,P=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],Q=u?new Uint8Array(P):P,R=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],ga=u?new Uint16Array(R):R,ha=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,
|
||||
13,13],U=u?new Uint8Array(ha):ha,V=new (u?Uint8Array:Array)(288),W,ia;W=0;for(ia=V.length;W<ia;++W)V[W]=143>=W?8:255>=W?9:279>=W?7:8;var da=D(V),X=new (u?Uint8Array:Array)(30),Y,ja;Y=0;for(ja=X.length;Y<ja;++Y)X[Y]=5;var ea=D(X);function J(e,c){for(var d=e.f,b=e.d,a=e.input,f=e.c,g=a.length,k;b<c;)f>=g&&n(Error("input buffer is broken")),d|=a[f++]<<b,b+=8;k=d&(1<<c)-1;e.f=d>>>c;e.d=b-c;e.c=f;return k}
|
||||
function Z(e,c){for(var d=e.f,b=e.d,a=e.input,f=e.c,g=a.length,k=c[0],m=c[1],p,t;b<m&&!(f>=g);)d|=a[f++]<<b,b+=8;p=k[d&(1<<m)-1];t=p>>>16;e.f=d>>t;e.d=b-t;e.c=f;return p&65535}
|
||||
function fa(e){function c(a,c,b){var d,e=this.w,f,g;for(g=0;g<a;)switch(d=Z(this,c),d){case 16:for(f=3+J(this,2);f--;)b[g++]=e;break;case 17:for(f=3+J(this,3);f--;)b[g++]=0;e=0;break;case 18:for(f=11+J(this,7);f--;)b[g++]=0;e=0;break;default:e=b[g++]=d}this.w=e;return b}var d=J(e,5)+257,b=J(e,5)+1,a=J(e,4)+4,f=new (u?Uint8Array:Array)(L.length),g,k,m,p;for(p=0;p<a;++p)f[L[p]]=J(e,3);if(!u){p=a;for(a=f.length;p<a;++p)f[L[p]]=0}g=D(f);k=new (u?Uint8Array:Array)(d);m=new (u?Uint8Array:Array)(b);e.w=
|
||||
0;e.l(D(c.call(e,d,g,k)),D(c.call(e,b,g,m)))}G.prototype.l=function(e,c){var d=this.b,b=this.a;this.r=e;for(var a=d.length-258,f,g,k,m;256!==(f=Z(this,e));)if(256>f)b>=a&&(this.a=b,d=this.e(),b=this.a),d[b++]=f;else{g=f-257;m=O[g];0<Q[g]&&(m+=J(this,Q[g]));f=Z(this,c);k=ga[f];0<U[f]&&(k+=J(this,U[f]));b>=a&&(this.a=b,d=this.e(),b=this.a);for(;m--;)d[b]=d[b++-k]}for(;8<=this.d;)this.d-=8,this.c--;this.a=b};
|
||||
G.prototype.D=function(e,c){var d=this.b,b=this.a;this.r=e;for(var a=d.length,f,g,k,m;256!==(f=Z(this,e));)if(256>f)b>=a&&(d=this.e(),a=d.length),d[b++]=f;else{g=f-257;m=O[g];0<Q[g]&&(m+=J(this,Q[g]));f=Z(this,c);k=ga[f];0<U[f]&&(k+=J(this,U[f]));b+m>a&&(d=this.e(),a=d.length);for(;m--;)d[b]=d[b++-k]}for(;8<=this.d;)this.d-=8,this.c--;this.a=b};
|
||||
G.prototype.e=function(){var e=new (u?Uint8Array:Array)(this.a-32768),c=this.a-32768,d,b,a=this.b;if(u)e.set(a.subarray(32768,e.length));else{d=0;for(b=e.length;d<b;++d)e[d]=a[d+32768]}this.i.push(e);this.n+=e.length;if(u)a.set(a.subarray(c,c+32768));else for(d=0;32768>d;++d)a[d]=a[c+d];this.a=32768;return a};
|
||||
G.prototype.F=function(e){var c,d=this.input.length/this.c+1|0,b,a,f,g=this.input,k=this.b;e&&("number"===typeof e.t&&(d=e.t),"number"===typeof e.A&&(d+=e.A));2>d?(b=(g.length-this.c)/this.r[2],f=258*(b/2)|0,a=f<k.length?k.length+f:k.length<<1):a=k.length*d;u?(c=new Uint8Array(a),c.set(k)):c=k;return this.b=c};
|
||||
G.prototype.q=function(){var e=0,c=this.b,d=this.i,b,a=new (u?Uint8Array:Array)(this.n+(this.a-32768)),f,g,k,m;if(0===d.length)return u?this.b.subarray(32768,this.a):this.b.slice(32768,this.a);f=0;for(g=d.length;f<g;++f){b=d[f];k=0;for(m=b.length;k<m;++k)a[e++]=b[k]}f=32768;for(g=this.a;f<g;++f)a[e++]=c[f];this.i=[];return this.buffer=a};
|
||||
G.prototype.B=function(){var e,c=this.a;u?this.z?(e=new Uint8Array(c),e.set(this.b.subarray(0,c))):e=this.b.subarray(0,c):(this.b.length>c&&(this.b.length=c),e=this.b);return this.buffer=e};function $(e){this.input=e;this.c=0;this.m=[];this.s=!1}$.prototype.G=function(){this.s||this.g();return this.m.slice()};
|
||||
$.prototype.g=function(){for(var e=this.input.length;this.c<e;){var c=new B,d=q,b=q,a=q,f=q,g=q,k=q,m=q,p=q,t=q,h=this.input,l=this.c;c.u=h[l++];c.v=h[l++];(31!==c.u||139!==c.v)&&n(Error("invalid file signature:"+c.u+","+c.v));c.p=h[l++];switch(c.p){case 8:break;default:n(Error("unknown compression method: "+c.p))}c.h=h[l++];p=h[l++]|h[l++]<<8|h[l++]<<16|h[l++]<<24;c.I=new Date(1E3*p);c.O=h[l++];c.N=h[l++];0<(c.h&4)&&(c.J=h[l++]|h[l++]<<8,l+=c.J);if(0<(c.h&8)){m=[];for(k=0;0<(g=h[l++]);)m[k++]=String.fromCharCode(g);
|
||||
c.name=m.join("")}if(0<(c.h&16)){m=[];for(k=0;0<(g=h[l++]);)m[k++]=String.fromCharCode(g);c.K=m.join("")}0<(c.h&2)&&(c.C=x(h,0,l)&65535,c.C!==(h[l++]|h[l++]<<8)&&n(Error("invalid header crc16")));d=h[h.length-4]|h[h.length-3]<<8|h[h.length-2]<<16|h[h.length-1]<<24;h.length-l-4-4<512*d&&(f=d);b=new G(h,{index:l,bufferSize:f});c.data=a=b.g();l=b.c;c.L=t=(h[l++]|h[l++]<<8|h[l++]<<16|h[l++]<<24)>>>0;x(a,q,q)!==t&&n(Error("invalid CRC-32 checksum: 0x"+x(a,q,q).toString(16)+" / 0x"+t.toString(16)));c.M=
|
||||
d=(h[l++]|h[l++]<<8|h[l++]<<16|h[l++]<<24)>>>0;(a.length&4294967295)!==d&&n(Error("invalid input size: "+(a.length&4294967295)+" / "+d));this.m.push(c);this.c=l}this.s=!0;var y=this.m,s,M,S=0,T=0,C;s=0;for(M=y.length;s<M;++s)T+=y[s].data.length;if(u){C=new Uint8Array(T);for(s=0;s<M;++s)C.set(y[s].data,S),S+=y[s].data.length}else{C=[];for(s=0;s<M;++s)C[s]=y[s].data;C=Array.prototype.concat.apply([],C)}return C};r("Zlib.Gunzip",$);r("Zlib.Gunzip.prototype.decompress",$.prototype.g);r("Zlib.Gunzip.prototype.getMembers",$.prototype.G);
|
||||
var Zlib=aa.Zlib;
|
||||
export { Zlib }
|
||||
17
libs/three.js/libs/inflate.module.min.js
vendored
Normal file
17
libs/three.js/libs/inflate.module.min.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */var mod={}, l=void 0,aa=mod;function r(c,d){var a=c.split("."),b=aa;!(a[0]in b)&&b.execScript&&b.execScript("var "+a[0]);for(var e;a.length&&(e=a.shift());)!a.length&&d!==l?b[e]=d:b=b[e]?b[e]:b[e]={}};var t="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array&&"undefined"!==typeof DataView;function v(c){var d=c.length,a=0,b=Number.POSITIVE_INFINITY,e,f,g,h,k,m,n,p,s,x;for(p=0;p<d;++p)c[p]>a&&(a=c[p]),c[p]<b&&(b=c[p]);e=1<<a;f=new (t?Uint32Array:Array)(e);g=1;h=0;for(k=2;g<=a;){for(p=0;p<d;++p)if(c[p]===g){m=0;n=h;for(s=0;s<g;++s)m=m<<1|n&1,n>>=1;x=g<<16|p;for(s=m;s<e;s+=k)f[s]=x;++h}++g;h<<=1;k<<=1}return[f,a,b]};function w(c,d){this.g=[];this.h=32768;this.d=this.f=this.a=this.l=0;this.input=t?new Uint8Array(c):c;this.m=!1;this.i=y;this.r=!1;if(d||!(d={}))d.index&&(this.a=d.index),d.bufferSize&&(this.h=d.bufferSize),d.bufferType&&(this.i=d.bufferType),d.resize&&(this.r=d.resize);switch(this.i){case A:this.b=32768;this.c=new (t?Uint8Array:Array)(32768+this.h+258);break;case y:this.b=0;this.c=new (t?Uint8Array:Array)(this.h);this.e=this.z;this.n=this.v;this.j=this.w;break;default:throw Error("invalid inflate mode");
|
||||
}}var A=0,y=1,B={t:A,s:y};
|
||||
w.prototype.k=function(){for(;!this.m;){var c=C(this,3);c&1&&(this.m=!0);c>>>=1;switch(c){case 0:var d=this.input,a=this.a,b=this.c,e=this.b,f=d.length,g=l,h=l,k=b.length,m=l;this.d=this.f=0;if(a+1>=f)throw Error("invalid uncompressed block header: LEN");g=d[a++]|d[a++]<<8;if(a+1>=f)throw Error("invalid uncompressed block header: NLEN");h=d[a++]|d[a++]<<8;if(g===~h)throw Error("invalid uncompressed block header: length verify");if(a+g>d.length)throw Error("input buffer is broken");switch(this.i){case A:for(;e+
|
||||
g>b.length;){m=k-e;g-=m;if(t)b.set(d.subarray(a,a+m),e),e+=m,a+=m;else for(;m--;)b[e++]=d[a++];this.b=e;b=this.e();e=this.b}break;case y:for(;e+g>b.length;)b=this.e({p:2});break;default:throw Error("invalid inflate mode");}if(t)b.set(d.subarray(a,a+g),e),e+=g,a+=g;else for(;g--;)b[e++]=d[a++];this.a=a;this.b=e;this.c=b;break;case 1:this.j(ba,ca);break;case 2:for(var n=C(this,5)+257,p=C(this,5)+1,s=C(this,4)+4,x=new (t?Uint8Array:Array)(D.length),S=l,T=l,U=l,u=l,M=l,F=l,z=l,q=l,V=l,q=0;q<s;++q)x[D[q]]=
|
||||
C(this,3);if(!t){q=s;for(s=x.length;q<s;++q)x[D[q]]=0}S=v(x);u=new (t?Uint8Array:Array)(n+p);q=0;for(V=n+p;q<V;)switch(M=E(this,S),M){case 16:for(z=3+C(this,2);z--;)u[q++]=F;break;case 17:for(z=3+C(this,3);z--;)u[q++]=0;F=0;break;case 18:for(z=11+C(this,7);z--;)u[q++]=0;F=0;break;default:F=u[q++]=M}T=t?v(u.subarray(0,n)):v(u.slice(0,n));U=t?v(u.subarray(n)):v(u.slice(n));this.j(T,U);break;default:throw Error("unknown BTYPE: "+c);}}return this.n()};
|
||||
var G=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],D=t?new Uint16Array(G):G,H=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],I=t?new Uint16Array(H):H,J=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],K=t?new Uint8Array(J):J,L=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],da=t?new Uint16Array(L):L,ea=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,
|
||||
13,13],N=t?new Uint8Array(ea):ea,O=new (t?Uint8Array:Array)(288),P,fa;P=0;for(fa=O.length;P<fa;++P)O[P]=143>=P?8:255>=P?9:279>=P?7:8;var ba=v(O),Q=new (t?Uint8Array:Array)(30),R,ga;R=0;for(ga=Q.length;R<ga;++R)Q[R]=5;var ca=v(Q);function C(c,d){for(var a=c.f,b=c.d,e=c.input,f=c.a,g=e.length,h;b<d;){if(f>=g)throw Error("input buffer is broken");a|=e[f++]<<b;b+=8}h=a&(1<<d)-1;c.f=a>>>d;c.d=b-d;c.a=f;return h}
|
||||
function E(c,d){for(var a=c.f,b=c.d,e=c.input,f=c.a,g=e.length,h=d[0],k=d[1],m,n;b<k&&!(f>=g);)a|=e[f++]<<b,b+=8;m=h[a&(1<<k)-1];n=m>>>16;if(n>b)throw Error("invalid code length: "+n);c.f=a>>n;c.d=b-n;c.a=f;return m&65535}
|
||||
w.prototype.j=function(c,d){var a=this.c,b=this.b;this.o=c;for(var e=a.length-258,f,g,h,k;256!==(f=E(this,c));)if(256>f)b>=e&&(this.b=b,a=this.e(),b=this.b),a[b++]=f;else{g=f-257;k=I[g];0<K[g]&&(k+=C(this,K[g]));f=E(this,d);h=da[f];0<N[f]&&(h+=C(this,N[f]));b>=e&&(this.b=b,a=this.e(),b=this.b);for(;k--;)a[b]=a[b++-h]}for(;8<=this.d;)this.d-=8,this.a--;this.b=b};
|
||||
w.prototype.w=function(c,d){var a=this.c,b=this.b;this.o=c;for(var e=a.length,f,g,h,k;256!==(f=E(this,c));)if(256>f)b>=e&&(a=this.e(),e=a.length),a[b++]=f;else{g=f-257;k=I[g];0<K[g]&&(k+=C(this,K[g]));f=E(this,d);h=da[f];0<N[f]&&(h+=C(this,N[f]));b+k>e&&(a=this.e(),e=a.length);for(;k--;)a[b]=a[b++-h]}for(;8<=this.d;)this.d-=8,this.a--;this.b=b};
|
||||
w.prototype.e=function(){var c=new (t?Uint8Array:Array)(this.b-32768),d=this.b-32768,a,b,e=this.c;if(t)c.set(e.subarray(32768,c.length));else{a=0;for(b=c.length;a<b;++a)c[a]=e[a+32768]}this.g.push(c);this.l+=c.length;if(t)e.set(e.subarray(d,d+32768));else for(a=0;32768>a;++a)e[a]=e[d+a];this.b=32768;return e};
|
||||
w.prototype.z=function(c){var d,a=this.input.length/this.a+1|0,b,e,f,g=this.input,h=this.c;c&&("number"===typeof c.p&&(a=c.p),"number"===typeof c.u&&(a+=c.u));2>a?(b=(g.length-this.a)/this.o[2],f=258*(b/2)|0,e=f<h.length?h.length+f:h.length<<1):e=h.length*a;t?(d=new Uint8Array(e),d.set(h)):d=h;return this.c=d};
|
||||
w.prototype.n=function(){var c=0,d=this.c,a=this.g,b,e=new (t?Uint8Array:Array)(this.l+(this.b-32768)),f,g,h,k;if(0===a.length)return t?this.c.subarray(32768,this.b):this.c.slice(32768,this.b);f=0;for(g=a.length;f<g;++f){b=a[f];h=0;for(k=b.length;h<k;++h)e[c++]=b[h]}f=32768;for(g=this.b;f<g;++f)e[c++]=d[f];this.g=[];return this.buffer=e};
|
||||
w.prototype.v=function(){var c,d=this.b;t?this.r?(c=new Uint8Array(d),c.set(this.c.subarray(0,d))):c=this.c.subarray(0,d):(this.c.length>d&&(this.c.length=d),c=this.c);return this.buffer=c};function W(c,d){var a,b;this.input=c;this.a=0;if(d||!(d={}))d.index&&(this.a=d.index),d.verify&&(this.A=d.verify);a=c[this.a++];b=c[this.a++];switch(a&15){case ha:this.method=ha;break;default:throw Error("unsupported compression method");}if(0!==((a<<8)+b)%31)throw Error("invalid fcheck flag:"+((a<<8)+b)%31);if(b&32)throw Error("fdict flag is not supported");this.q=new w(c,{index:this.a,bufferSize:d.bufferSize,bufferType:d.bufferType,resize:d.resize})}
|
||||
W.prototype.k=function(){var c=this.input,d,a;d=this.q.k();this.a=this.q.a;if(this.A){a=(c[this.a++]<<24|c[this.a++]<<16|c[this.a++]<<8|c[this.a++])>>>0;var b=d;if("string"===typeof b){var e=b.split(""),f,g;f=0;for(g=e.length;f<g;f++)e[f]=(e[f].charCodeAt(0)&255)>>>0;b=e}for(var h=1,k=0,m=b.length,n,p=0;0<m;){n=1024<m?1024:m;m-=n;do h+=b[p++],k+=h;while(--n);h%=65521;k%=65521}if(a!==(k<<16|h)>>>0)throw Error("invalid adler-32 checksum");}return d};var ha=8;r("Zlib.Inflate",W);r("Zlib.Inflate.prototype.decompress",W.prototype.k);var X={ADAPTIVE:B.s,BLOCK:B.t},Y,Z,$,ia;if(Object.keys)Y=Object.keys(X);else for(Z in Y=[],$=0,X)Y[$++]=Z;$=0;for(ia=Y.length;$<ia;++$)Z=Y[$],r("Zlib.Inflate.BufferType."+Z,X[Z]);
|
||||
var Inflate=mod.Zlib.Inflate;
|
||||
export { Inflate }
|
||||
15
libs/three.js/libs/jszip.module.min.js
vendored
Normal file
15
libs/three.js/libs/jszip.module.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
113
libs/three.js/libs/meshopt_decoder.module.js
Normal file
113
libs/three.js/libs/meshopt_decoder.module.js
Normal file
File diff suppressed because one or more lines are too long
11535
libs/three.js/libs/mmdparser.module.js
Normal file
11535
libs/three.js/libs/mmdparser.module.js
Normal file
File diff suppressed because it is too large
Load Diff
397
libs/three.js/libs/motion-controllers.module.js
Normal file
397
libs/three.js/libs/motion-controllers.module.js
Normal file
@ -0,0 +1,397 @@
|
||||
/**
|
||||
* @webxr-input-profiles/motion-controllers 1.0.0 https://github.com/immersive-web/webxr-input-profiles
|
||||
*/
|
||||
|
||||
const Constants = {
|
||||
Handedness: Object.freeze({
|
||||
NONE: 'none',
|
||||
LEFT: 'left',
|
||||
RIGHT: 'right'
|
||||
}),
|
||||
|
||||
ComponentState: Object.freeze({
|
||||
DEFAULT: 'default',
|
||||
TOUCHED: 'touched',
|
||||
PRESSED: 'pressed'
|
||||
}),
|
||||
|
||||
ComponentProperty: Object.freeze({
|
||||
BUTTON: 'button',
|
||||
X_AXIS: 'xAxis',
|
||||
Y_AXIS: 'yAxis',
|
||||
STATE: 'state'
|
||||
}),
|
||||
|
||||
ComponentType: Object.freeze({
|
||||
TRIGGER: 'trigger',
|
||||
SQUEEZE: 'squeeze',
|
||||
TOUCHPAD: 'touchpad',
|
||||
THUMBSTICK: 'thumbstick',
|
||||
BUTTON: 'button'
|
||||
}),
|
||||
|
||||
ButtonTouchThreshold: 0.05,
|
||||
|
||||
AxisTouchThreshold: 0.1,
|
||||
|
||||
VisualResponseProperty: Object.freeze({
|
||||
TRANSFORM: 'transform',
|
||||
VISIBILITY: 'visibility'
|
||||
})
|
||||
};
|
||||
|
||||
/**
|
||||
* @description Static helper function to fetch a JSON file and turn it into a JS object
|
||||
* @param {string} path - Path to JSON file to be fetched
|
||||
*/
|
||||
async function fetchJsonFile(path) {
|
||||
const response = await fetch(path);
|
||||
if (!response.ok) {
|
||||
throw new Error(response.statusText);
|
||||
} else {
|
||||
return response.json();
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchProfilesList(basePath) {
|
||||
if (!basePath) {
|
||||
throw new Error('No basePath supplied');
|
||||
}
|
||||
|
||||
const profileListFileName = 'profilesList.json';
|
||||
const profilesList = await fetchJsonFile(`${basePath}/${profileListFileName}`);
|
||||
return profilesList;
|
||||
}
|
||||
|
||||
async function fetchProfile(xrInputSource, basePath, defaultProfile = null, getAssetPath = true) {
|
||||
if (!xrInputSource) {
|
||||
throw new Error('No xrInputSource supplied');
|
||||
}
|
||||
|
||||
if (!basePath) {
|
||||
throw new Error('No basePath supplied');
|
||||
}
|
||||
|
||||
// Get the list of profiles
|
||||
const supportedProfilesList = await fetchProfilesList(basePath);
|
||||
|
||||
// Find the relative path to the first requested profile that is recognized
|
||||
let match;
|
||||
xrInputSource.profiles.some((profileId) => {
|
||||
const supportedProfile = supportedProfilesList[profileId];
|
||||
if (supportedProfile) {
|
||||
match = {
|
||||
profileId,
|
||||
profilePath: `${basePath}/${supportedProfile.path}`,
|
||||
deprecated: !!supportedProfile.deprecated
|
||||
};
|
||||
}
|
||||
return !!match;
|
||||
});
|
||||
|
||||
if (!match) {
|
||||
if (!defaultProfile) {
|
||||
throw new Error('No matching profile name found');
|
||||
}
|
||||
|
||||
const supportedProfile = supportedProfilesList[defaultProfile];
|
||||
if (!supportedProfile) {
|
||||
throw new Error(`No matching profile name found and default profile "${defaultProfile}" missing.`);
|
||||
}
|
||||
|
||||
match = {
|
||||
profileId: defaultProfile,
|
||||
profilePath: `${basePath}/${supportedProfile.path}`,
|
||||
deprecated: !!supportedProfile.deprecated
|
||||
};
|
||||
}
|
||||
|
||||
const profile = await fetchJsonFile(match.profilePath);
|
||||
|
||||
let assetPath;
|
||||
if (getAssetPath) {
|
||||
let layout;
|
||||
if (xrInputSource.handedness === 'any') {
|
||||
layout = profile.layouts[Object.keys(profile.layouts)[0]];
|
||||
} else {
|
||||
layout = profile.layouts[xrInputSource.handedness];
|
||||
}
|
||||
if (!layout) {
|
||||
throw new Error(
|
||||
`No matching handedness, ${xrInputSource.handedness}, in profile ${match.profileId}`
|
||||
);
|
||||
}
|
||||
|
||||
if (layout.assetPath) {
|
||||
assetPath = match.profilePath.replace('profile.json', layout.assetPath);
|
||||
}
|
||||
}
|
||||
|
||||
return { profile, assetPath };
|
||||
}
|
||||
|
||||
/** @constant {Object} */
|
||||
const defaultComponentValues = {
|
||||
xAxis: 0,
|
||||
yAxis: 0,
|
||||
button: 0,
|
||||
state: Constants.ComponentState.DEFAULT
|
||||
};
|
||||
|
||||
/**
|
||||
* @description Converts an X, Y coordinate from the range -1 to 1 (as reported by the Gamepad
|
||||
* API) to the range 0 to 1 (for interpolation). Also caps the X, Y values to be bounded within
|
||||
* a circle. This ensures that thumbsticks are not animated outside the bounds of their physical
|
||||
* range of motion and touchpads do not report touch locations off their physical bounds.
|
||||
* @param {number} x The original x coordinate in the range -1 to 1
|
||||
* @param {number} y The original y coordinate in the range -1 to 1
|
||||
*/
|
||||
function normalizeAxes(x = 0, y = 0) {
|
||||
let xAxis = x;
|
||||
let yAxis = y;
|
||||
|
||||
// Determine if the point is outside the bounds of the circle
|
||||
// and, if so, place it on the edge of the circle
|
||||
const hypotenuse = Math.sqrt((x * x) + (y * y));
|
||||
if (hypotenuse > 1) {
|
||||
const theta = Math.atan2(y, x);
|
||||
xAxis = Math.cos(theta);
|
||||
yAxis = Math.sin(theta);
|
||||
}
|
||||
|
||||
// Scale and move the circle so values are in the interpolation range. The circle's origin moves
|
||||
// from (0, 0) to (0.5, 0.5). The circle's radius scales from 1 to be 0.5.
|
||||
const result = {
|
||||
normalizedXAxis: (xAxis * 0.5) + 0.5,
|
||||
normalizedYAxis: (yAxis * 0.5) + 0.5
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the description of how the 3D model should visually respond to a specific user input.
|
||||
* This is accomplished by initializing the object with the name of a node in the 3D model and
|
||||
* property that need to be modified in response to user input, the name of the nodes representing
|
||||
* the allowable range of motion, and the name of the input which triggers the change. In response
|
||||
* to the named input changing, this object computes the appropriate weighting to use for
|
||||
* interpolating between the range of motion nodes.
|
||||
*/
|
||||
class VisualResponse {
|
||||
constructor(visualResponseDescription) {
|
||||
this.componentProperty = visualResponseDescription.componentProperty;
|
||||
this.states = visualResponseDescription.states;
|
||||
this.valueNodeName = visualResponseDescription.valueNodeName;
|
||||
this.valueNodeProperty = visualResponseDescription.valueNodeProperty;
|
||||
|
||||
if (this.valueNodeProperty === Constants.VisualResponseProperty.TRANSFORM) {
|
||||
this.minNodeName = visualResponseDescription.minNodeName;
|
||||
this.maxNodeName = visualResponseDescription.maxNodeName;
|
||||
}
|
||||
|
||||
// Initializes the response's current value based on default data
|
||||
this.value = 0;
|
||||
this.updateFromComponent(defaultComponentValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the visual response's interpolation weight based on component state
|
||||
* @param {Object} componentValues - The component from which to update
|
||||
* @param {number} xAxis - The reported X axis value of the component
|
||||
* @param {number} yAxis - The reported Y axis value of the component
|
||||
* @param {number} button - The reported value of the component's button
|
||||
* @param {string} state - The component's active state
|
||||
*/
|
||||
updateFromComponent({
|
||||
xAxis, yAxis, button, state
|
||||
}) {
|
||||
const { normalizedXAxis, normalizedYAxis } = normalizeAxes(xAxis, yAxis);
|
||||
switch (this.componentProperty) {
|
||||
case Constants.ComponentProperty.X_AXIS:
|
||||
this.value = (this.states.includes(state)) ? normalizedXAxis : 0.5;
|
||||
break;
|
||||
case Constants.ComponentProperty.Y_AXIS:
|
||||
this.value = (this.states.includes(state)) ? normalizedYAxis : 0.5;
|
||||
break;
|
||||
case Constants.ComponentProperty.BUTTON:
|
||||
this.value = (this.states.includes(state)) ? button : 0;
|
||||
break;
|
||||
case Constants.ComponentProperty.STATE:
|
||||
if (this.valueNodeProperty === Constants.VisualResponseProperty.VISIBILITY) {
|
||||
this.value = (this.states.includes(state));
|
||||
} else {
|
||||
this.value = this.states.includes(state) ? 1.0 : 0.0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Component {
|
||||
/**
|
||||
* @param {Object} componentId - Id of the component
|
||||
* @param {Object} componentDescription - Description of the component to be created
|
||||
*/
|
||||
constructor(componentId, componentDescription) {
|
||||
if (!componentId
|
||||
|| !componentDescription
|
||||
|| !componentDescription.visualResponses
|
||||
|| !componentDescription.gamepadIndices
|
||||
|| Object.keys(componentDescription.gamepadIndices).length === 0) {
|
||||
throw new Error('Invalid arguments supplied');
|
||||
}
|
||||
|
||||
this.id = componentId;
|
||||
this.type = componentDescription.type;
|
||||
this.rootNodeName = componentDescription.rootNodeName;
|
||||
this.touchPointNodeName = componentDescription.touchPointNodeName;
|
||||
|
||||
// Build all the visual responses for this component
|
||||
this.visualResponses = {};
|
||||
Object.keys(componentDescription.visualResponses).forEach((responseName) => {
|
||||
const visualResponse = new VisualResponse(componentDescription.visualResponses[responseName]);
|
||||
this.visualResponses[responseName] = visualResponse;
|
||||
});
|
||||
|
||||
// Set default values
|
||||
this.gamepadIndices = Object.assign({}, componentDescription.gamepadIndices);
|
||||
|
||||
this.values = {
|
||||
state: Constants.ComponentState.DEFAULT,
|
||||
button: (this.gamepadIndices.button !== undefined) ? 0 : undefined,
|
||||
xAxis: (this.gamepadIndices.xAxis !== undefined) ? 0 : undefined,
|
||||
yAxis: (this.gamepadIndices.yAxis !== undefined) ? 0 : undefined
|
||||
};
|
||||
}
|
||||
|
||||
get data() {
|
||||
const data = { id: this.id, ...this.values };
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Poll for updated data based on current gamepad state
|
||||
* @param {Object} gamepad - The gamepad object from which the component data should be polled
|
||||
*/
|
||||
updateFromGamepad(gamepad) {
|
||||
// Set the state to default before processing other data sources
|
||||
this.values.state = Constants.ComponentState.DEFAULT;
|
||||
|
||||
// Get and normalize button
|
||||
if (this.gamepadIndices.button !== undefined
|
||||
&& gamepad.buttons.length > this.gamepadIndices.button) {
|
||||
const gamepadButton = gamepad.buttons[this.gamepadIndices.button];
|
||||
this.values.button = gamepadButton.value;
|
||||
this.values.button = (this.values.button < 0) ? 0 : this.values.button;
|
||||
this.values.button = (this.values.button > 1) ? 1 : this.values.button;
|
||||
|
||||
// Set the state based on the button
|
||||
if (gamepadButton.pressed || this.values.button === 1) {
|
||||
this.values.state = Constants.ComponentState.PRESSED;
|
||||
} else if (gamepadButton.touched || this.values.button > Constants.ButtonTouchThreshold) {
|
||||
this.values.state = Constants.ComponentState.TOUCHED;
|
||||
}
|
||||
}
|
||||
|
||||
// Get and normalize x axis value
|
||||
if (this.gamepadIndices.xAxis !== undefined
|
||||
&& gamepad.axes.length > this.gamepadIndices.xAxis) {
|
||||
this.values.xAxis = gamepad.axes[this.gamepadIndices.xAxis];
|
||||
this.values.xAxis = (this.values.xAxis < -1) ? -1 : this.values.xAxis;
|
||||
this.values.xAxis = (this.values.xAxis > 1) ? 1 : this.values.xAxis;
|
||||
|
||||
// If the state is still default, check if the xAxis makes it touched
|
||||
if (this.values.state === Constants.ComponentState.DEFAULT
|
||||
&& Math.abs(this.values.xAxis) > Constants.AxisTouchThreshold) {
|
||||
this.values.state = Constants.ComponentState.TOUCHED;
|
||||
}
|
||||
}
|
||||
|
||||
// Get and normalize Y axis value
|
||||
if (this.gamepadIndices.yAxis !== undefined
|
||||
&& gamepad.axes.length > this.gamepadIndices.yAxis) {
|
||||
this.values.yAxis = gamepad.axes[this.gamepadIndices.yAxis];
|
||||
this.values.yAxis = (this.values.yAxis < -1) ? -1 : this.values.yAxis;
|
||||
this.values.yAxis = (this.values.yAxis > 1) ? 1 : this.values.yAxis;
|
||||
|
||||
// If the state is still default, check if the yAxis makes it touched
|
||||
if (this.values.state === Constants.ComponentState.DEFAULT
|
||||
&& Math.abs(this.values.yAxis) > Constants.AxisTouchThreshold) {
|
||||
this.values.state = Constants.ComponentState.TOUCHED;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the visual response weights based on the current component data
|
||||
Object.values(this.visualResponses).forEach((visualResponse) => {
|
||||
visualResponse.updateFromComponent(this.values);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Builds a motion controller with components and visual responses based on the
|
||||
* supplied profile description. Data is polled from the xrInputSource's gamepad.
|
||||
* @author Nell Waliczek / https://github.com/NellWaliczek
|
||||
*/
|
||||
class MotionController {
|
||||
/**
|
||||
* @param {Object} xrInputSource - The XRInputSource to build the MotionController around
|
||||
* @param {Object} profile - The best matched profile description for the supplied xrInputSource
|
||||
* @param {Object} assetUrl
|
||||
*/
|
||||
constructor(xrInputSource, profile, assetUrl) {
|
||||
if (!xrInputSource) {
|
||||
throw new Error('No xrInputSource supplied');
|
||||
}
|
||||
|
||||
if (!profile) {
|
||||
throw new Error('No profile supplied');
|
||||
}
|
||||
|
||||
this.xrInputSource = xrInputSource;
|
||||
this.assetUrl = assetUrl;
|
||||
this.id = profile.profileId;
|
||||
|
||||
// Build child components as described in the profile description
|
||||
this.layoutDescription = profile.layouts[xrInputSource.handedness];
|
||||
this.components = {};
|
||||
Object.keys(this.layoutDescription.components).forEach((componentId) => {
|
||||
const componentDescription = this.layoutDescription.components[componentId];
|
||||
this.components[componentId] = new Component(componentId, componentDescription);
|
||||
});
|
||||
|
||||
// Initialize components based on current gamepad state
|
||||
this.updateFromGamepad();
|
||||
}
|
||||
|
||||
get gripSpace() {
|
||||
return this.xrInputSource.gripSpace;
|
||||
}
|
||||
|
||||
get targetRaySpace() {
|
||||
return this.xrInputSource.targetRaySpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns a subset of component data for simplified debugging
|
||||
*/
|
||||
get data() {
|
||||
const data = [];
|
||||
Object.values(this.components).forEach((component) => {
|
||||
data.push(component.data);
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Poll for updated data based on current gamepad state
|
||||
*/
|
||||
updateFromGamepad() {
|
||||
Object.values(this.components).forEach((component) => {
|
||||
component.updateFromGamepad(this.xrInputSource.gamepad);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { Constants, MotionController, fetchProfile, fetchProfilesList };
|
||||
119
libs/three.js/libs/opentype.module.min.js
vendored
Normal file
119
libs/three.js/libs/opentype.module.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
167
libs/three.js/libs/stats.module.js
Normal file
167
libs/three.js/libs/stats.module.js
Normal file
@ -0,0 +1,167 @@
|
||||
var Stats = function () {
|
||||
|
||||
var mode = 0;
|
||||
|
||||
var container = document.createElement( 'div' );
|
||||
container.style.cssText = 'position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000';
|
||||
container.addEventListener( 'click', function ( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
showPanel( ++ mode % container.children.length );
|
||||
|
||||
}, false );
|
||||
|
||||
//
|
||||
|
||||
function addPanel( panel ) {
|
||||
|
||||
container.appendChild( panel.dom );
|
||||
return panel;
|
||||
|
||||
}
|
||||
|
||||
function showPanel( id ) {
|
||||
|
||||
for ( var i = 0; i < container.children.length; i ++ ) {
|
||||
|
||||
container.children[ i ].style.display = i === id ? 'block' : 'none';
|
||||
|
||||
}
|
||||
|
||||
mode = id;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
var beginTime = ( performance || Date ).now(), prevTime = beginTime, frames = 0;
|
||||
|
||||
var fpsPanel = addPanel( new Stats.Panel( 'FPS', '#0ff', '#002' ) );
|
||||
var msPanel = addPanel( new Stats.Panel( 'MS', '#0f0', '#020' ) );
|
||||
|
||||
if ( self.performance && self.performance.memory ) {
|
||||
|
||||
var memPanel = addPanel( new Stats.Panel( 'MB', '#f08', '#201' ) );
|
||||
|
||||
}
|
||||
|
||||
showPanel( 0 );
|
||||
|
||||
return {
|
||||
|
||||
REVISION: 16,
|
||||
|
||||
dom: container,
|
||||
|
||||
addPanel: addPanel,
|
||||
showPanel: showPanel,
|
||||
|
||||
begin: function () {
|
||||
|
||||
beginTime = ( performance || Date ).now();
|
||||
|
||||
},
|
||||
|
||||
end: function () {
|
||||
|
||||
frames ++;
|
||||
|
||||
var time = ( performance || Date ).now();
|
||||
|
||||
msPanel.update( time - beginTime, 200 );
|
||||
|
||||
if ( time >= prevTime + 1000 ) {
|
||||
|
||||
fpsPanel.update( ( frames * 1000 ) / ( time - prevTime ), 100 );
|
||||
|
||||
prevTime = time;
|
||||
frames = 0;
|
||||
|
||||
if ( memPanel ) {
|
||||
|
||||
var memory = performance.memory;
|
||||
memPanel.update( memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return time;
|
||||
|
||||
},
|
||||
|
||||
update: function () {
|
||||
|
||||
beginTime = this.end();
|
||||
|
||||
},
|
||||
|
||||
// Backwards Compatibility
|
||||
|
||||
domElement: container,
|
||||
setMode: showPanel
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
Stats.Panel = function ( name, fg, bg ) {
|
||||
|
||||
var min = Infinity, max = 0, round = Math.round;
|
||||
var PR = round( window.devicePixelRatio || 1 );
|
||||
|
||||
var WIDTH = 80 * PR, HEIGHT = 48 * PR,
|
||||
TEXT_X = 3 * PR, TEXT_Y = 2 * PR,
|
||||
GRAPH_X = 3 * PR, GRAPH_Y = 15 * PR,
|
||||
GRAPH_WIDTH = 74 * PR, GRAPH_HEIGHT = 30 * PR;
|
||||
|
||||
var canvas = document.createElement( 'canvas' );
|
||||
canvas.width = WIDTH;
|
||||
canvas.height = HEIGHT;
|
||||
canvas.style.cssText = 'width:80px;height:48px';
|
||||
|
||||
var context = canvas.getContext( '2d' );
|
||||
context.font = 'bold ' + ( 9 * PR ) + 'px Helvetica,Arial,sans-serif';
|
||||
context.textBaseline = 'top';
|
||||
|
||||
context.fillStyle = bg;
|
||||
context.fillRect( 0, 0, WIDTH, HEIGHT );
|
||||
|
||||
context.fillStyle = fg;
|
||||
context.fillText( name, TEXT_X, TEXT_Y );
|
||||
context.fillRect( GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT );
|
||||
|
||||
context.fillStyle = bg;
|
||||
context.globalAlpha = 0.9;
|
||||
context.fillRect( GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT );
|
||||
|
||||
return {
|
||||
|
||||
dom: canvas,
|
||||
|
||||
update: function ( value, maxValue ) {
|
||||
|
||||
min = Math.min( min, value );
|
||||
max = Math.max( max, value );
|
||||
|
||||
context.fillStyle = bg;
|
||||
context.globalAlpha = 1;
|
||||
context.fillRect( 0, 0, WIDTH, GRAPH_Y );
|
||||
context.fillStyle = fg;
|
||||
context.fillText( round( value ) + ' ' + name + ' (' + round( min ) + '-' + round( max ) + ')', TEXT_X, TEXT_Y );
|
||||
|
||||
context.drawImage( canvas, GRAPH_X + PR, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT, GRAPH_X, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT );
|
||||
|
||||
context.fillRect( GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT );
|
||||
|
||||
context.fillStyle = bg;
|
||||
context.globalAlpha = 0.9;
|
||||
context.fillRect( GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round( ( 1 - ( value / maxValue ) ) * GRAPH_HEIGHT ) );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
export default Stats;
|
||||
3
libs/three.js/libs/tween.module.min.js
vendored
Normal file
3
libs/three.js/libs/tween.module.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
115
libs/three.js/libs/zstddec.module.js
Normal file
115
libs/three.js/libs/zstddec.module.js
Normal file
File diff suppressed because one or more lines are too long
24
libs/three.js/lines/Line2.js
Normal file
24
libs/three.js/lines/Line2.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { LineSegments2 } from '../lines/LineSegments2.js';
|
||||
import { LineGeometry } from '../lines/LineGeometry.js';
|
||||
import { LineMaterial } from '../lines/LineMaterial.js';
|
||||
|
||||
var Line2 = function ( geometry, material ) {
|
||||
|
||||
if ( geometry === undefined ) geometry = new LineGeometry();
|
||||
if ( material === undefined ) material = new LineMaterial( { color: Math.random() * 0xffffff } );
|
||||
|
||||
LineSegments2.call( this, geometry, material );
|
||||
|
||||
this.type = 'Line2';
|
||||
|
||||
};
|
||||
|
||||
Line2.prototype = Object.assign( Object.create( LineSegments2.prototype ), {
|
||||
|
||||
constructor: Line2,
|
||||
|
||||
isLine2: true
|
||||
|
||||
} );
|
||||
|
||||
export { Line2 };
|
||||
97
libs/three.js/lines/LineGeometry.js
Normal file
97
libs/three.js/lines/LineGeometry.js
Normal file
@ -0,0 +1,97 @@
|
||||
import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';
|
||||
|
||||
var LineGeometry = function () {
|
||||
|
||||
LineSegmentsGeometry.call( this );
|
||||
|
||||
this.type = 'LineGeometry';
|
||||
|
||||
};
|
||||
|
||||
LineGeometry.prototype = Object.assign( Object.create( LineSegmentsGeometry.prototype ), {
|
||||
|
||||
constructor: LineGeometry,
|
||||
|
||||
isLineGeometry: true,
|
||||
|
||||
setPositions: function ( array ) {
|
||||
|
||||
// converts [ x1, y1, z1, x2, y2, z2, ... ] to pairs format
|
||||
|
||||
var length = array.length - 3;
|
||||
var points = new Float32Array( 2 * length );
|
||||
|
||||
for ( var i = 0; i < length; i += 3 ) {
|
||||
|
||||
points[ 2 * i ] = array[ i ];
|
||||
points[ 2 * i + 1 ] = array[ i + 1 ];
|
||||
points[ 2 * i + 2 ] = array[ i + 2 ];
|
||||
|
||||
points[ 2 * i + 3 ] = array[ i + 3 ];
|
||||
points[ 2 * i + 4 ] = array[ i + 4 ];
|
||||
points[ 2 * i + 5 ] = array[ i + 5 ];
|
||||
|
||||
}
|
||||
|
||||
LineSegmentsGeometry.prototype.setPositions.call( this, points );
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
setColors: function ( array ) {
|
||||
|
||||
// converts [ r1, g1, b1, r2, g2, b2, ... ] to pairs format
|
||||
|
||||
var length = array.length - 3;
|
||||
var colors = new Float32Array( 2 * length );
|
||||
|
||||
for ( var i = 0; i < length; i += 3 ) {
|
||||
|
||||
colors[ 2 * i ] = array[ i ];
|
||||
colors[ 2 * i + 1 ] = array[ i + 1 ];
|
||||
colors[ 2 * i + 2 ] = array[ i + 2 ];
|
||||
|
||||
colors[ 2 * i + 3 ] = array[ i + 3 ];
|
||||
colors[ 2 * i + 4 ] = array[ i + 4 ];
|
||||
colors[ 2 * i + 5 ] = array[ i + 5 ];
|
||||
|
||||
}
|
||||
|
||||
LineSegmentsGeometry.prototype.setColors.call( this, colors );
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
fromLine: function ( line ) {
|
||||
|
||||
var geometry = line.geometry;
|
||||
|
||||
if ( geometry.isGeometry ) {
|
||||
|
||||
this.setPositions( geometry.vertices );
|
||||
|
||||
} else if ( geometry.isBufferGeometry ) {
|
||||
|
||||
this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
|
||||
|
||||
}
|
||||
|
||||
// set colors, maybe
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
copy: function ( /* source */ ) {
|
||||
|
||||
// todo
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
export { LineGeometry };
|
||||
424
libs/three.js/lines/LineMaterial.js
Normal file
424
libs/three.js/lines/LineMaterial.js
Normal file
@ -0,0 +1,424 @@
|
||||
import {
|
||||
ShaderLib,
|
||||
ShaderMaterial,
|
||||
UniformsLib,
|
||||
UniformsUtils,
|
||||
Vector2
|
||||
} from '../build/three.module.js';
|
||||
|
||||
/**
|
||||
* parameters = {
|
||||
* color: <hex>,
|
||||
* linewidth: <float>,
|
||||
* dashed: <boolean>,
|
||||
* dashScale: <float>,
|
||||
* dashSize: <float>,
|
||||
* dashOffset: <float>,
|
||||
* gapSize: <float>,
|
||||
* resolution: <Vector2>, // to be set by renderer
|
||||
* }
|
||||
*/
|
||||
|
||||
UniformsLib.line = {
|
||||
|
||||
linewidth: { value: 1 },
|
||||
resolution: { value: new Vector2( 1, 1 ) },
|
||||
dashScale: { value: 1 },
|
||||
dashSize: { value: 1 },
|
||||
dashOffset: { value: 0 },
|
||||
gapSize: { value: 1 }, // todo FIX - maybe change to totalSize
|
||||
opacity: { value: 1 }
|
||||
|
||||
};
|
||||
|
||||
ShaderLib[ 'line' ] = {
|
||||
|
||||
uniforms: UniformsUtils.merge( [
|
||||
UniformsLib.common,
|
||||
UniformsLib.fog,
|
||||
UniformsLib.line
|
||||
] ),
|
||||
|
||||
vertexShader:
|
||||
`
|
||||
#include <common>
|
||||
#include <color_pars_vertex>
|
||||
#include <fog_pars_vertex>
|
||||
#include <logdepthbuf_pars_vertex>
|
||||
#include <clipping_planes_pars_vertex>
|
||||
|
||||
uniform float linewidth;
|
||||
uniform vec2 resolution;
|
||||
|
||||
attribute vec3 instanceStart;
|
||||
attribute vec3 instanceEnd;
|
||||
|
||||
attribute vec3 instanceColorStart;
|
||||
attribute vec3 instanceColorEnd;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
#ifdef USE_DASH
|
||||
|
||||
uniform float dashScale;
|
||||
attribute float instanceDistanceStart;
|
||||
attribute float instanceDistanceEnd;
|
||||
varying float vLineDistance;
|
||||
|
||||
#endif
|
||||
|
||||
void trimSegment( const in vec4 start, inout vec4 end ) {
|
||||
|
||||
// trim end segment so it terminates between the camera plane and the near plane
|
||||
|
||||
// conservative estimate of the near plane
|
||||
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
|
||||
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
|
||||
float nearEstimate = - 0.5 * b / a;
|
||||
|
||||
float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
|
||||
|
||||
end.xyz = mix( start.xyz, end.xyz, alpha );
|
||||
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
#ifdef USE_COLOR
|
||||
|
||||
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_DASH
|
||||
|
||||
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
|
||||
|
||||
#endif
|
||||
|
||||
float aspect = resolution.x / resolution.y;
|
||||
|
||||
vUv = uv;
|
||||
|
||||
// camera space
|
||||
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
||||
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
||||
|
||||
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
||||
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
||||
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
||||
// perhaps there is a more elegant solution -- WestLangley
|
||||
|
||||
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
|
||||
|
||||
if ( perspective ) {
|
||||
|
||||
if ( start.z < 0.0 && end.z >= 0.0 ) {
|
||||
|
||||
trimSegment( start, end );
|
||||
|
||||
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
|
||||
|
||||
trimSegment( end, start );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// clip space
|
||||
vec4 clipStart = projectionMatrix * start;
|
||||
vec4 clipEnd = projectionMatrix * end;
|
||||
|
||||
// ndc space
|
||||
vec2 ndcStart = clipStart.xy / clipStart.w;
|
||||
vec2 ndcEnd = clipEnd.xy / clipEnd.w;
|
||||
|
||||
// direction
|
||||
vec2 dir = ndcEnd - ndcStart;
|
||||
|
||||
// account for clip-space aspect ratio
|
||||
dir.x *= aspect;
|
||||
dir = normalize( dir );
|
||||
|
||||
// perpendicular to dir
|
||||
vec2 offset = vec2( dir.y, - dir.x );
|
||||
|
||||
// undo aspect ratio adjustment
|
||||
dir.x /= aspect;
|
||||
offset.x /= aspect;
|
||||
|
||||
// sign flip
|
||||
if ( position.x < 0.0 ) offset *= - 1.0;
|
||||
|
||||
// endcaps
|
||||
if ( position.y < 0.0 ) {
|
||||
|
||||
offset += - dir;
|
||||
|
||||
} else if ( position.y > 1.0 ) {
|
||||
|
||||
offset += dir;
|
||||
|
||||
}
|
||||
|
||||
// adjust for linewidth
|
||||
offset *= linewidth;
|
||||
|
||||
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
||||
offset /= resolution.y;
|
||||
|
||||
// select end
|
||||
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
||||
|
||||
// back to clip space
|
||||
offset *= clip.w;
|
||||
|
||||
clip.xy += offset;
|
||||
|
||||
gl_Position = clip;
|
||||
|
||||
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
|
||||
|
||||
#include <logdepthbuf_vertex>
|
||||
#include <clipping_planes_vertex>
|
||||
#include <fog_vertex>
|
||||
|
||||
}
|
||||
`,
|
||||
|
||||
fragmentShader:
|
||||
`
|
||||
uniform vec3 diffuse;
|
||||
uniform float opacity;
|
||||
|
||||
#ifdef USE_DASH
|
||||
|
||||
uniform float dashSize;
|
||||
uniform float dashOffset;
|
||||
uniform float gapSize;
|
||||
|
||||
#endif
|
||||
|
||||
varying float vLineDistance;
|
||||
|
||||
#include <common>
|
||||
#include <color_pars_fragment>
|
||||
#include <fog_pars_fragment>
|
||||
#include <logdepthbuf_pars_fragment>
|
||||
#include <clipping_planes_pars_fragment>
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
|
||||
#include <clipping_planes_fragment>
|
||||
|
||||
#ifdef USE_DASH
|
||||
|
||||
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
|
||||
|
||||
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
|
||||
|
||||
#endif
|
||||
|
||||
if ( abs( vUv.y ) > 1.0 ) {
|
||||
|
||||
float a = vUv.x;
|
||||
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
||||
float len2 = a * a + b * b;
|
||||
|
||||
if ( len2 > 1.0 ) discard;
|
||||
|
||||
}
|
||||
|
||||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||||
|
||||
#include <logdepthbuf_fragment>
|
||||
#include <color_fragment>
|
||||
|
||||
gl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );
|
||||
|
||||
#include <tonemapping_fragment>
|
||||
#include <encodings_fragment>
|
||||
#include <fog_fragment>
|
||||
#include <premultiplied_alpha_fragment>
|
||||
|
||||
}
|
||||
`
|
||||
};
|
||||
|
||||
var LineMaterial = function ( parameters ) {
|
||||
|
||||
ShaderMaterial.call( this, {
|
||||
|
||||
type: 'LineMaterial',
|
||||
|
||||
uniforms: UniformsUtils.clone( ShaderLib[ 'line' ].uniforms ),
|
||||
|
||||
vertexShader: ShaderLib[ 'line' ].vertexShader,
|
||||
fragmentShader: ShaderLib[ 'line' ].fragmentShader,
|
||||
|
||||
clipping: true // required for clipping support
|
||||
|
||||
} );
|
||||
|
||||
this.dashed = false;
|
||||
|
||||
Object.defineProperties( this, {
|
||||
|
||||
color: {
|
||||
|
||||
enumerable: true,
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.uniforms.diffuse.value;
|
||||
|
||||
},
|
||||
|
||||
set: function ( value ) {
|
||||
|
||||
this.uniforms.diffuse.value = value;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
linewidth: {
|
||||
|
||||
enumerable: true,
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.uniforms.linewidth.value;
|
||||
|
||||
},
|
||||
|
||||
set: function ( value ) {
|
||||
|
||||
this.uniforms.linewidth.value = value;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
dashScale: {
|
||||
|
||||
enumerable: true,
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.uniforms.dashScale.value;
|
||||
|
||||
},
|
||||
|
||||
set: function ( value ) {
|
||||
|
||||
this.uniforms.dashScale.value = value;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
dashSize: {
|
||||
|
||||
enumerable: true,
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.uniforms.dashSize.value;
|
||||
|
||||
},
|
||||
|
||||
set: function ( value ) {
|
||||
|
||||
this.uniforms.dashSize.value = value;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
dashOffset: {
|
||||
|
||||
enumerable: true,
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.uniforms.dashOffset.value;
|
||||
|
||||
},
|
||||
|
||||
set: function ( value ) {
|
||||
|
||||
this.uniforms.dashOffset.value = value;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
gapSize: {
|
||||
|
||||
enumerable: true,
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.uniforms.gapSize.value;
|
||||
|
||||
},
|
||||
|
||||
set: function ( value ) {
|
||||
|
||||
this.uniforms.gapSize.value = value;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
opacity: {
|
||||
|
||||
enumerable: true,
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.uniforms.opacity.value;
|
||||
|
||||
},
|
||||
|
||||
set: function ( value ) {
|
||||
|
||||
this.uniforms.opacity.value = value;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
resolution: {
|
||||
|
||||
enumerable: true,
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.uniforms.resolution.value;
|
||||
|
||||
},
|
||||
|
||||
set: function ( value ) {
|
||||
|
||||
this.uniforms.resolution.value.copy( value );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
this.setValues( parameters );
|
||||
|
||||
};
|
||||
|
||||
LineMaterial.prototype = Object.create( ShaderMaterial.prototype );
|
||||
LineMaterial.prototype.constructor = LineMaterial;
|
||||
|
||||
LineMaterial.prototype.isLineMaterial = true;
|
||||
|
||||
export { LineMaterial };
|
||||
209
libs/three.js/lines/LineSegments2.js
Normal file
209
libs/three.js/lines/LineSegments2.js
Normal file
@ -0,0 +1,209 @@
|
||||
import {
|
||||
InstancedInterleavedBuffer,
|
||||
InterleavedBufferAttribute,
|
||||
Line3,
|
||||
MathUtils,
|
||||
Matrix4,
|
||||
Mesh,
|
||||
Vector3,
|
||||
Vector4
|
||||
} from '../build/three.module.js';
|
||||
import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';
|
||||
import { LineMaterial } from '../lines/LineMaterial.js';
|
||||
|
||||
var LineSegments2 = function ( geometry, material ) {
|
||||
|
||||
if ( geometry === undefined ) geometry = new LineSegmentsGeometry();
|
||||
if ( material === undefined ) material = new LineMaterial( { color: Math.random() * 0xffffff } );
|
||||
|
||||
Mesh.call( this, geometry, material );
|
||||
|
||||
this.type = 'LineSegments2';
|
||||
|
||||
};
|
||||
|
||||
LineSegments2.prototype = Object.assign( Object.create( Mesh.prototype ), {
|
||||
|
||||
constructor: LineSegments2,
|
||||
|
||||
isLineSegments2: true,
|
||||
|
||||
computeLineDistances: ( function () { // for backwards-compatability, but could be a method of LineSegmentsGeometry...
|
||||
|
||||
var start = new Vector3();
|
||||
var end = new Vector3();
|
||||
|
||||
return function computeLineDistances() {
|
||||
|
||||
var geometry = this.geometry;
|
||||
|
||||
var instanceStart = geometry.attributes.instanceStart;
|
||||
var instanceEnd = geometry.attributes.instanceEnd;
|
||||
var lineDistances = new Float32Array( 2 * instanceStart.data.count );
|
||||
|
||||
for ( var i = 0, j = 0, l = instanceStart.data.count; i < l; i ++, j += 2 ) {
|
||||
|
||||
start.fromBufferAttribute( instanceStart, i );
|
||||
end.fromBufferAttribute( instanceEnd, i );
|
||||
|
||||
lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];
|
||||
lineDistances[ j + 1 ] = lineDistances[ j ] + start.distanceTo( end );
|
||||
|
||||
}
|
||||
|
||||
var instanceDistanceBuffer = new InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
|
||||
|
||||
geometry.setAttribute( 'instanceDistanceStart', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
||||
geometry.setAttribute( 'instanceDistanceEnd', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
}() ),
|
||||
|
||||
raycast: ( function () {
|
||||
|
||||
var start = new Vector4();
|
||||
var end = new Vector4();
|
||||
|
||||
var ssOrigin = new Vector4();
|
||||
var ssOrigin3 = new Vector3();
|
||||
var mvMatrix = new Matrix4();
|
||||
var line = new Line3();
|
||||
var closestPoint = new Vector3();
|
||||
|
||||
return function raycast( raycaster, intersects ) {
|
||||
|
||||
if ( raycaster.camera === null ) {
|
||||
|
||||
console.error( 'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.' );
|
||||
|
||||
}
|
||||
|
||||
var threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0;
|
||||
|
||||
var ray = raycaster.ray;
|
||||
var camera = raycaster.camera;
|
||||
var projectionMatrix = camera.projectionMatrix;
|
||||
|
||||
var geometry = this.geometry;
|
||||
var material = this.material;
|
||||
var resolution = material.resolution;
|
||||
var lineWidth = material.linewidth + threshold;
|
||||
|
||||
var instanceStart = geometry.attributes.instanceStart;
|
||||
var instanceEnd = geometry.attributes.instanceEnd;
|
||||
|
||||
// pick a point 1 unit out along the ray to avoid the ray origin
|
||||
// sitting at the camera origin which will cause "w" to be 0 when
|
||||
// applying the projection matrix.
|
||||
ray.at( 1, ssOrigin );
|
||||
|
||||
// ndc space [ - 1.0, 1.0 ]
|
||||
ssOrigin.w = 1;
|
||||
ssOrigin.applyMatrix4( camera.matrixWorldInverse );
|
||||
ssOrigin.applyMatrix4( projectionMatrix );
|
||||
ssOrigin.multiplyScalar( 1 / ssOrigin.w );
|
||||
|
||||
// screen space
|
||||
ssOrigin.x *= resolution.x / 2;
|
||||
ssOrigin.y *= resolution.y / 2;
|
||||
ssOrigin.z = 0;
|
||||
|
||||
ssOrigin3.copy( ssOrigin );
|
||||
|
||||
var matrixWorld = this.matrixWorld;
|
||||
mvMatrix.multiplyMatrices( camera.matrixWorldInverse, matrixWorld );
|
||||
|
||||
for ( var i = 0, l = instanceStart.count; i < l; i ++ ) {
|
||||
|
||||
start.fromBufferAttribute( instanceStart, i );
|
||||
end.fromBufferAttribute( instanceEnd, i );
|
||||
|
||||
start.w = 1;
|
||||
end.w = 1;
|
||||
|
||||
// camera space
|
||||
start.applyMatrix4( mvMatrix );
|
||||
end.applyMatrix4( mvMatrix );
|
||||
|
||||
// clip space
|
||||
start.applyMatrix4( projectionMatrix );
|
||||
end.applyMatrix4( projectionMatrix );
|
||||
|
||||
// ndc space [ - 1.0, 1.0 ]
|
||||
start.multiplyScalar( 1 / start.w );
|
||||
end.multiplyScalar( 1 / end.w );
|
||||
|
||||
// skip the segment if it's outside the camera near and far planes
|
||||
var isBehindCameraNear = start.z < - 1 && end.z < - 1;
|
||||
var isPastCameraFar = start.z > 1 && end.z > 1;
|
||||
if ( isBehindCameraNear || isPastCameraFar ) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
// screen space
|
||||
start.x *= resolution.x / 2;
|
||||
start.y *= resolution.y / 2;
|
||||
|
||||
end.x *= resolution.x / 2;
|
||||
end.y *= resolution.y / 2;
|
||||
|
||||
// create 2d segment
|
||||
line.start.copy( start );
|
||||
line.start.z = 0;
|
||||
|
||||
line.end.copy( end );
|
||||
line.end.z = 0;
|
||||
|
||||
// get closest point on ray to segment
|
||||
var param = line.closestPointToPointParameter( ssOrigin3, true );
|
||||
line.at( param, closestPoint );
|
||||
|
||||
// check if the intersection point is within clip space
|
||||
var zPos = MathUtils.lerp( start.z, end.z, param );
|
||||
var isInClipSpace = zPos >= - 1 && zPos <= 1;
|
||||
|
||||
var isInside = ssOrigin3.distanceTo( closestPoint ) < lineWidth * 0.5;
|
||||
|
||||
if ( isInClipSpace && isInside ) {
|
||||
|
||||
line.start.fromBufferAttribute( instanceStart, i );
|
||||
line.end.fromBufferAttribute( instanceEnd, i );
|
||||
|
||||
line.start.applyMatrix4( matrixWorld );
|
||||
line.end.applyMatrix4( matrixWorld );
|
||||
|
||||
var pointOnLine = new Vector3();
|
||||
var point = new Vector3();
|
||||
|
||||
ray.distanceSqToSegment( line.start, line.end, point, pointOnLine );
|
||||
|
||||
intersects.push( {
|
||||
|
||||
point: point,
|
||||
pointOnLine: pointOnLine,
|
||||
distance: ray.origin.distanceTo( point ),
|
||||
|
||||
object: this,
|
||||
face: null,
|
||||
faceIndex: i,
|
||||
uv: null,
|
||||
uv2: null,
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}() )
|
||||
|
||||
} );
|
||||
|
||||
export { LineSegments2 };
|
||||
260
libs/three.js/lines/LineSegmentsGeometry.js
Normal file
260
libs/three.js/lines/LineSegmentsGeometry.js
Normal file
@ -0,0 +1,260 @@
|
||||
import {
|
||||
Box3,
|
||||
Float32BufferAttribute,
|
||||
InstancedBufferGeometry,
|
||||
InstancedInterleavedBuffer,
|
||||
InterleavedBufferAttribute,
|
||||
Sphere,
|
||||
Vector3,
|
||||
WireframeGeometry
|
||||
} from '../build/three.module.js';
|
||||
|
||||
var LineSegmentsGeometry = function () {
|
||||
|
||||
InstancedBufferGeometry.call( this );
|
||||
|
||||
this.type = 'LineSegmentsGeometry';
|
||||
|
||||
var positions = [ - 1, 2, 0, 1, 2, 0, - 1, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 0, - 1, - 1, 0, 1, - 1, 0 ];
|
||||
var uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ];
|
||||
var index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];
|
||||
|
||||
this.setIndex( index );
|
||||
this.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
|
||||
this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
|
||||
|
||||
};
|
||||
|
||||
LineSegmentsGeometry.prototype = Object.assign( Object.create( InstancedBufferGeometry.prototype ), {
|
||||
|
||||
constructor: LineSegmentsGeometry,
|
||||
|
||||
isLineSegmentsGeometry: true,
|
||||
|
||||
applyMatrix4: function ( matrix ) {
|
||||
|
||||
var start = this.attributes.instanceStart;
|
||||
var end = this.attributes.instanceEnd;
|
||||
|
||||
if ( start !== undefined ) {
|
||||
|
||||
start.applyMatrix4( matrix );
|
||||
|
||||
end.applyMatrix4( matrix );
|
||||
|
||||
start.needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
if ( this.boundingBox !== null ) {
|
||||
|
||||
this.computeBoundingBox();
|
||||
|
||||
}
|
||||
|
||||
if ( this.boundingSphere !== null ) {
|
||||
|
||||
this.computeBoundingSphere();
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
setPositions: function ( array ) {
|
||||
|
||||
var lineSegments;
|
||||
|
||||
if ( array instanceof Float32Array ) {
|
||||
|
||||
lineSegments = array;
|
||||
|
||||
} else if ( Array.isArray( array ) ) {
|
||||
|
||||
lineSegments = new Float32Array( array );
|
||||
|
||||
}
|
||||
|
||||
var instanceBuffer = new InstancedInterleavedBuffer( lineSegments, 6, 1 ); // xyz, xyz
|
||||
|
||||
this.setAttribute( 'instanceStart', new InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz
|
||||
this.setAttribute( 'instanceEnd', new InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz
|
||||
|
||||
//
|
||||
|
||||
this.computeBoundingBox();
|
||||
this.computeBoundingSphere();
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
setColors: function ( array ) {
|
||||
|
||||
var colors;
|
||||
|
||||
if ( array instanceof Float32Array ) {
|
||||
|
||||
colors = array;
|
||||
|
||||
} else if ( Array.isArray( array ) ) {
|
||||
|
||||
colors = new Float32Array( array );
|
||||
|
||||
}
|
||||
|
||||
var instanceColorBuffer = new InstancedInterleavedBuffer( colors, 6, 1 ); // rgb, rgb
|
||||
|
||||
this.setAttribute( 'instanceColorStart', new InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb
|
||||
this.setAttribute( 'instanceColorEnd', new InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
fromWireframeGeometry: function ( geometry ) {
|
||||
|
||||
this.setPositions( geometry.attributes.position.array );
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
fromEdgesGeometry: function ( geometry ) {
|
||||
|
||||
this.setPositions( geometry.attributes.position.array );
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
fromMesh: function ( mesh ) {
|
||||
|
||||
this.fromWireframeGeometry( new WireframeGeometry( mesh.geometry ) );
|
||||
|
||||
// set colors, maybe
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
fromLineSegments: function ( lineSegments ) {
|
||||
|
||||
var geometry = lineSegments.geometry;
|
||||
|
||||
if ( geometry.isGeometry ) {
|
||||
|
||||
this.setPositions( geometry.vertices );
|
||||
|
||||
} else if ( geometry.isBufferGeometry ) {
|
||||
|
||||
this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
|
||||
|
||||
}
|
||||
|
||||
// set colors, maybe
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
computeBoundingBox: function () {
|
||||
|
||||
var box = new Box3();
|
||||
|
||||
return function computeBoundingBox() {
|
||||
|
||||
if ( this.boundingBox === null ) {
|
||||
|
||||
this.boundingBox = new Box3();
|
||||
|
||||
}
|
||||
|
||||
var start = this.attributes.instanceStart;
|
||||
var end = this.attributes.instanceEnd;
|
||||
|
||||
if ( start !== undefined && end !== undefined ) {
|
||||
|
||||
this.boundingBox.setFromBufferAttribute( start );
|
||||
|
||||
box.setFromBufferAttribute( end );
|
||||
|
||||
this.boundingBox.union( box );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}(),
|
||||
|
||||
computeBoundingSphere: function () {
|
||||
|
||||
var vector = new Vector3();
|
||||
|
||||
return function computeBoundingSphere() {
|
||||
|
||||
if ( this.boundingSphere === null ) {
|
||||
|
||||
this.boundingSphere = new Sphere();
|
||||
|
||||
}
|
||||
|
||||
if ( this.boundingBox === null ) {
|
||||
|
||||
this.computeBoundingBox();
|
||||
|
||||
}
|
||||
|
||||
var start = this.attributes.instanceStart;
|
||||
var end = this.attributes.instanceEnd;
|
||||
|
||||
if ( start !== undefined && end !== undefined ) {
|
||||
|
||||
var center = this.boundingSphere.center;
|
||||
|
||||
this.boundingBox.getCenter( center );
|
||||
|
||||
var maxRadiusSq = 0;
|
||||
|
||||
for ( var i = 0, il = start.count; i < il; i ++ ) {
|
||||
|
||||
vector.fromBufferAttribute( start, i );
|
||||
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
|
||||
|
||||
vector.fromBufferAttribute( end, i );
|
||||
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
|
||||
|
||||
}
|
||||
|
||||
this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
|
||||
|
||||
if ( isNaN( this.boundingSphere.radius ) ) {
|
||||
|
||||
console.error( 'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.', this );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}(),
|
||||
|
||||
toJSON: function () {
|
||||
|
||||
// todo
|
||||
|
||||
},
|
||||
|
||||
applyMatrix: function ( matrix ) {
|
||||
|
||||
console.warn( 'THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().' );
|
||||
|
||||
return this.applyMatrix4( matrix );
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
export { LineSegmentsGeometry };
|
||||
63
libs/three.js/lines/Wireframe.js
Normal file
63
libs/three.js/lines/Wireframe.js
Normal file
@ -0,0 +1,63 @@
|
||||
import {
|
||||
InstancedInterleavedBuffer,
|
||||
InterleavedBufferAttribute,
|
||||
Mesh,
|
||||
Vector3
|
||||
} from '../build/three.module.js';
|
||||
import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';
|
||||
import { LineMaterial } from '../lines/LineMaterial.js';
|
||||
|
||||
var Wireframe = function ( geometry, material ) {
|
||||
|
||||
Mesh.call( this );
|
||||
|
||||
this.type = 'Wireframe';
|
||||
|
||||
this.geometry = geometry !== undefined ? geometry : new LineSegmentsGeometry();
|
||||
this.material = material !== undefined ? material : new LineMaterial( { color: Math.random() * 0xffffff } );
|
||||
|
||||
};
|
||||
|
||||
Wireframe.prototype = Object.assign( Object.create( Mesh.prototype ), {
|
||||
|
||||
constructor: Wireframe,
|
||||
|
||||
isWireframe: true,
|
||||
|
||||
computeLineDistances: ( function () { // for backwards-compatability, but could be a method of LineSegmentsGeometry...
|
||||
|
||||
var start = new Vector3();
|
||||
var end = new Vector3();
|
||||
|
||||
return function computeLineDistances() {
|
||||
|
||||
var geometry = this.geometry;
|
||||
|
||||
var instanceStart = geometry.attributes.instanceStart;
|
||||
var instanceEnd = geometry.attributes.instanceEnd;
|
||||
var lineDistances = new Float32Array( 2 * instanceStart.data.count );
|
||||
|
||||
for ( var i = 0, j = 0, l = instanceStart.data.count; i < l; i ++, j += 2 ) {
|
||||
|
||||
start.fromBufferAttribute( instanceStart, i );
|
||||
end.fromBufferAttribute( instanceEnd, i );
|
||||
|
||||
lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];
|
||||
lineDistances[ j + 1 ] = lineDistances[ j ] + start.distanceTo( end );
|
||||
|
||||
}
|
||||
|
||||
var instanceDistanceBuffer = new InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
|
||||
|
||||
geometry.setAttribute( 'instanceDistanceStart', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
||||
geometry.setAttribute( 'instanceDistanceEnd', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
}() )
|
||||
|
||||
} );
|
||||
|
||||
export { Wireframe };
|
||||
26
libs/three.js/lines/WireframeGeometry2.js
Normal file
26
libs/three.js/lines/WireframeGeometry2.js
Normal file
@ -0,0 +1,26 @@
|
||||
import {
|
||||
WireframeGeometry
|
||||
} from '../build/three.module.js';
|
||||
import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';
|
||||
|
||||
var WireframeGeometry2 = function ( geometry ) {
|
||||
|
||||
LineSegmentsGeometry.call( this );
|
||||
|
||||
this.type = 'WireframeGeometry2';
|
||||
|
||||
this.fromWireframeGeometry( new WireframeGeometry( geometry ) );
|
||||
|
||||
// set colors, maybe
|
||||
|
||||
};
|
||||
|
||||
WireframeGeometry2.prototype = Object.assign( Object.create( LineSegmentsGeometry.prototype ), {
|
||||
|
||||
constructor: WireframeGeometry2,
|
||||
|
||||
isWireframeGeometry2: true
|
||||
|
||||
} );
|
||||
|
||||
export { WireframeGeometry2 };
|
||||
1411
libs/three.js/loaders/3DMLoader.js
Normal file
1411
libs/three.js/loaders/3DMLoader.js
Normal file
File diff suppressed because it is too large
Load Diff
1472
libs/three.js/loaders/3MFLoader.js
Normal file
1472
libs/three.js/loaders/3MFLoader.js
Normal file
File diff suppressed because it is too large
Load Diff
522
libs/three.js/loaders/AMFLoader.js
Normal file
522
libs/three.js/loaders/AMFLoader.js
Normal file
@ -0,0 +1,522 @@
|
||||
import {
|
||||
BufferGeometry,
|
||||
Color,
|
||||
FileLoader,
|
||||
Float32BufferAttribute,
|
||||
Group,
|
||||
Loader,
|
||||
LoaderUtils,
|
||||
Mesh,
|
||||
MeshPhongMaterial
|
||||
} from '../../../build/three.module.js';
|
||||
import { JSZip } from '../libs/jszip.module.min.js';
|
||||
|
||||
/**
|
||||
* Description: Early release of an AMF Loader following the pattern of the
|
||||
* example loaders in the three.js project.
|
||||
*
|
||||
* More information about the AMF format: http://amf.wikispaces.com
|
||||
*
|
||||
* Usage:
|
||||
* var loader = new AMFLoader();
|
||||
* loader.load('/path/to/project.amf', function(objecttree) {
|
||||
* scene.add(objecttree);
|
||||
* });
|
||||
*
|
||||
* Materials now supported, material colors supported
|
||||
* Zip support, requires jszip
|
||||
* No constellation support (yet)!
|
||||
*
|
||||
*/
|
||||
|
||||
var AMFLoader = function ( manager ) {
|
||||
|
||||
Loader.call( this, manager );
|
||||
|
||||
};
|
||||
|
||||
AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
|
||||
|
||||
constructor: AMFLoader,
|
||||
|
||||
load: function ( url, onLoad, onProgress, onError ) {
|
||||
|
||||
var scope = this;
|
||||
|
||||
var loader = new FileLoader( scope.manager );
|
||||
loader.setPath( scope.path );
|
||||
loader.setResponseType( 'arraybuffer' );
|
||||
loader.setRequestHeader( scope.requestHeader );
|
||||
loader.setWithCredentials( scope.withCredentials );
|
||||
loader.load( url, function ( text ) {
|
||||
|
||||
try {
|
||||
|
||||
onLoad( scope.parse( text ) );
|
||||
|
||||
} catch ( e ) {
|
||||
|
||||
if ( onError ) {
|
||||
|
||||
onError( e );
|
||||
|
||||
} else {
|
||||
|
||||
console.error( e );
|
||||
|
||||
}
|
||||
|
||||
scope.manager.itemError( url );
|
||||
|
||||
}
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
},
|
||||
|
||||
parse: function ( data ) {
|
||||
|
||||
function loadDocument( data ) {
|
||||
|
||||
var view = new DataView( data );
|
||||
var magic = String.fromCharCode( view.getUint8( 0 ), view.getUint8( 1 ) );
|
||||
|
||||
if ( magic === 'PK' ) {
|
||||
|
||||
var zip = null;
|
||||
var file = null;
|
||||
|
||||
console.log( 'THREE.AMFLoader: Loading Zip' );
|
||||
|
||||
try {
|
||||
|
||||
zip = new JSZip( data ); // eslint-disable-line no-undef
|
||||
|
||||
} catch ( e ) {
|
||||
|
||||
if ( e instanceof ReferenceError ) {
|
||||
|
||||
console.log( 'THREE.AMFLoader: jszip missing and file is compressed.' );
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for ( file in zip.files ) {
|
||||
|
||||
if ( file.toLowerCase().substr( - 4 ) === '.amf' ) {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log( 'THREE.AMFLoader: Trying to load file asset: ' + file );
|
||||
view = new DataView( zip.file( file ).asArrayBuffer() );
|
||||
|
||||
}
|
||||
|
||||
var fileText = LoaderUtils.decodeText( view );
|
||||
var xmlData = new DOMParser().parseFromString( fileText, 'application/xml' );
|
||||
|
||||
if ( xmlData.documentElement.nodeName.toLowerCase() !== 'amf' ) {
|
||||
|
||||
console.log( 'THREE.AMFLoader: Error loading AMF - no AMF document found.' );
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
return xmlData;
|
||||
|
||||
}
|
||||
|
||||
function loadDocumentScale( node ) {
|
||||
|
||||
var scale = 1.0;
|
||||
var unit = 'millimeter';
|
||||
|
||||
if ( node.documentElement.attributes.unit !== undefined ) {
|
||||
|
||||
unit = node.documentElement.attributes.unit.value.toLowerCase();
|
||||
|
||||
}
|
||||
|
||||
var scaleUnits = {
|
||||
millimeter: 1.0,
|
||||
inch: 25.4,
|
||||
feet: 304.8,
|
||||
meter: 1000.0,
|
||||
micron: 0.001
|
||||
};
|
||||
|
||||
if ( scaleUnits[ unit ] !== undefined ) {
|
||||
|
||||
scale = scaleUnits[ unit ];
|
||||
|
||||
}
|
||||
|
||||
console.log( 'THREE.AMFLoader: Unit scale: ' + scale );
|
||||
return scale;
|
||||
|
||||
}
|
||||
|
||||
function loadMaterials( node ) {
|
||||
|
||||
var matName = 'AMF Material';
|
||||
var matId = node.attributes.id.textContent;
|
||||
var color = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };
|
||||
|
||||
var loadedMaterial = null;
|
||||
|
||||
for ( var i = 0; i < node.childNodes.length; i ++ ) {
|
||||
|
||||
var matChildEl = node.childNodes[ i ];
|
||||
|
||||
if ( matChildEl.nodeName === 'metadata' && matChildEl.attributes.type !== undefined ) {
|
||||
|
||||
if ( matChildEl.attributes.type.value === 'name' ) {
|
||||
|
||||
matName = matChildEl.textContent;
|
||||
|
||||
}
|
||||
|
||||
} else if ( matChildEl.nodeName === 'color' ) {
|
||||
|
||||
color = loadColor( matChildEl );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
loadedMaterial = new MeshPhongMaterial( {
|
||||
flatShading: true,
|
||||
color: new Color( color.r, color.g, color.b ),
|
||||
name: matName
|
||||
} );
|
||||
|
||||
if ( color.a !== 1.0 ) {
|
||||
|
||||
loadedMaterial.transparent = true;
|
||||
loadedMaterial.opacity = color.a;
|
||||
|
||||
}
|
||||
|
||||
return { id: matId, material: loadedMaterial };
|
||||
|
||||
}
|
||||
|
||||
function loadColor( node ) {
|
||||
|
||||
var color = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };
|
||||
|
||||
for ( var i = 0; i < node.childNodes.length; i ++ ) {
|
||||
|
||||
var matColor = node.childNodes[ i ];
|
||||
|
||||
if ( matColor.nodeName === 'r' ) {
|
||||
|
||||
color.r = matColor.textContent;
|
||||
|
||||
} else if ( matColor.nodeName === 'g' ) {
|
||||
|
||||
color.g = matColor.textContent;
|
||||
|
||||
} else if ( matColor.nodeName === 'b' ) {
|
||||
|
||||
color.b = matColor.textContent;
|
||||
|
||||
} else if ( matColor.nodeName === 'a' ) {
|
||||
|
||||
color.a = matColor.textContent;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return color;
|
||||
|
||||
}
|
||||
|
||||
function loadMeshVolume( node ) {
|
||||
|
||||
var volume = { name: '', triangles: [], materialid: null };
|
||||
|
||||
var currVolumeNode = node.firstElementChild;
|
||||
|
||||
if ( node.attributes.materialid !== undefined ) {
|
||||
|
||||
volume.materialId = node.attributes.materialid.nodeValue;
|
||||
|
||||
}
|
||||
|
||||
while ( currVolumeNode ) {
|
||||
|
||||
if ( currVolumeNode.nodeName === 'metadata' ) {
|
||||
|
||||
if ( currVolumeNode.attributes.type !== undefined ) {
|
||||
|
||||
if ( currVolumeNode.attributes.type.value === 'name' ) {
|
||||
|
||||
volume.name = currVolumeNode.textContent;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if ( currVolumeNode.nodeName === 'triangle' ) {
|
||||
|
||||
var v1 = currVolumeNode.getElementsByTagName( 'v1' )[ 0 ].textContent;
|
||||
var v2 = currVolumeNode.getElementsByTagName( 'v2' )[ 0 ].textContent;
|
||||
var v3 = currVolumeNode.getElementsByTagName( 'v3' )[ 0 ].textContent;
|
||||
|
||||
volume.triangles.push( v1, v2, v3 );
|
||||
|
||||
}
|
||||
|
||||
currVolumeNode = currVolumeNode.nextElementSibling;
|
||||
|
||||
}
|
||||
|
||||
return volume;
|
||||
|
||||
}
|
||||
|
||||
function loadMeshVertices( node ) {
|
||||
|
||||
var vertArray = [];
|
||||
var normalArray = [];
|
||||
var currVerticesNode = node.firstElementChild;
|
||||
|
||||
while ( currVerticesNode ) {
|
||||
|
||||
if ( currVerticesNode.nodeName === 'vertex' ) {
|
||||
|
||||
var vNode = currVerticesNode.firstElementChild;
|
||||
|
||||
while ( vNode ) {
|
||||
|
||||
if ( vNode.nodeName === 'coordinates' ) {
|
||||
|
||||
var x = vNode.getElementsByTagName( 'x' )[ 0 ].textContent;
|
||||
var y = vNode.getElementsByTagName( 'y' )[ 0 ].textContent;
|
||||
var z = vNode.getElementsByTagName( 'z' )[ 0 ].textContent;
|
||||
|
||||
vertArray.push( x, y, z );
|
||||
|
||||
} else if ( vNode.nodeName === 'normal' ) {
|
||||
|
||||
var nx = vNode.getElementsByTagName( 'nx' )[ 0 ].textContent;
|
||||
var ny = vNode.getElementsByTagName( 'ny' )[ 0 ].textContent;
|
||||
var nz = vNode.getElementsByTagName( 'nz' )[ 0 ].textContent;
|
||||
|
||||
normalArray.push( nx, ny, nz );
|
||||
|
||||
}
|
||||
|
||||
vNode = vNode.nextElementSibling;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
currVerticesNode = currVerticesNode.nextElementSibling;
|
||||
|
||||
}
|
||||
|
||||
return { 'vertices': vertArray, 'normals': normalArray };
|
||||
|
||||
}
|
||||
|
||||
function loadObject( node ) {
|
||||
|
||||
var objId = node.attributes.id.textContent;
|
||||
var loadedObject = { name: 'amfobject', meshes: [] };
|
||||
var currColor = null;
|
||||
var currObjNode = node.firstElementChild;
|
||||
|
||||
while ( currObjNode ) {
|
||||
|
||||
if ( currObjNode.nodeName === 'metadata' ) {
|
||||
|
||||
if ( currObjNode.attributes.type !== undefined ) {
|
||||
|
||||
if ( currObjNode.attributes.type.value === 'name' ) {
|
||||
|
||||
loadedObject.name = currObjNode.textContent;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if ( currObjNode.nodeName === 'color' ) {
|
||||
|
||||
currColor = loadColor( currObjNode );
|
||||
|
||||
} else if ( currObjNode.nodeName === 'mesh' ) {
|
||||
|
||||
var currMeshNode = currObjNode.firstElementChild;
|
||||
var mesh = { vertices: [], normals: [], volumes: [], color: currColor };
|
||||
|
||||
while ( currMeshNode ) {
|
||||
|
||||
if ( currMeshNode.nodeName === 'vertices' ) {
|
||||
|
||||
var loadedVertices = loadMeshVertices( currMeshNode );
|
||||
|
||||
mesh.normals = mesh.normals.concat( loadedVertices.normals );
|
||||
mesh.vertices = mesh.vertices.concat( loadedVertices.vertices );
|
||||
|
||||
} else if ( currMeshNode.nodeName === 'volume' ) {
|
||||
|
||||
mesh.volumes.push( loadMeshVolume( currMeshNode ) );
|
||||
|
||||
}
|
||||
|
||||
currMeshNode = currMeshNode.nextElementSibling;
|
||||
|
||||
}
|
||||
|
||||
loadedObject.meshes.push( mesh );
|
||||
|
||||
}
|
||||
|
||||
currObjNode = currObjNode.nextElementSibling;
|
||||
|
||||
}
|
||||
|
||||
return { 'id': objId, 'obj': loadedObject };
|
||||
|
||||
}
|
||||
|
||||
var xmlData = loadDocument( data );
|
||||
var amfName = '';
|
||||
var amfAuthor = '';
|
||||
var amfScale = loadDocumentScale( xmlData );
|
||||
var amfMaterials = {};
|
||||
var amfObjects = {};
|
||||
var childNodes = xmlData.documentElement.childNodes;
|
||||
|
||||
var i, j;
|
||||
|
||||
for ( i = 0; i < childNodes.length; i ++ ) {
|
||||
|
||||
var child = childNodes[ i ];
|
||||
|
||||
if ( child.nodeName === 'metadata' ) {
|
||||
|
||||
if ( child.attributes.type !== undefined ) {
|
||||
|
||||
if ( child.attributes.type.value === 'name' ) {
|
||||
|
||||
amfName = child.textContent;
|
||||
|
||||
} else if ( child.attributes.type.value === 'author' ) {
|
||||
|
||||
amfAuthor = child.textContent;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if ( child.nodeName === 'material' ) {
|
||||
|
||||
var loadedMaterial = loadMaterials( child );
|
||||
|
||||
amfMaterials[ loadedMaterial.id ] = loadedMaterial.material;
|
||||
|
||||
} else if ( child.nodeName === 'object' ) {
|
||||
|
||||
var loadedObject = loadObject( child );
|
||||
|
||||
amfObjects[ loadedObject.id ] = loadedObject.obj;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var sceneObject = new Group();
|
||||
var defaultMaterial = new MeshPhongMaterial( { color: 0xaaaaff, flatShading: true } );
|
||||
|
||||
sceneObject.name = amfName;
|
||||
sceneObject.userData.author = amfAuthor;
|
||||
sceneObject.userData.loader = 'AMF';
|
||||
|
||||
for ( var id in amfObjects ) {
|
||||
|
||||
var part = amfObjects[ id ];
|
||||
var meshes = part.meshes;
|
||||
var newObject = new Group();
|
||||
newObject.name = part.name || '';
|
||||
|
||||
for ( i = 0; i < meshes.length; i ++ ) {
|
||||
|
||||
var objDefaultMaterial = defaultMaterial;
|
||||
var mesh = meshes[ i ];
|
||||
var vertices = new Float32BufferAttribute( mesh.vertices, 3 );
|
||||
var normals = null;
|
||||
|
||||
if ( mesh.normals.length ) {
|
||||
|
||||
normals = new Float32BufferAttribute( mesh.normals, 3 );
|
||||
|
||||
}
|
||||
|
||||
if ( mesh.color ) {
|
||||
|
||||
var color = mesh.color;
|
||||
|
||||
objDefaultMaterial = defaultMaterial.clone();
|
||||
objDefaultMaterial.color = new Color( color.r, color.g, color.b );
|
||||
|
||||
if ( color.a !== 1.0 ) {
|
||||
|
||||
objDefaultMaterial.transparent = true;
|
||||
objDefaultMaterial.opacity = color.a;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var volumes = mesh.volumes;
|
||||
|
||||
for ( j = 0; j < volumes.length; j ++ ) {
|
||||
|
||||
var volume = volumes[ j ];
|
||||
var newGeometry = new BufferGeometry();
|
||||
var material = objDefaultMaterial;
|
||||
|
||||
newGeometry.setIndex( volume.triangles );
|
||||
newGeometry.setAttribute( 'position', vertices.clone() );
|
||||
|
||||
if ( normals ) {
|
||||
|
||||
newGeometry.setAttribute( 'normal', normals.clone() );
|
||||
|
||||
}
|
||||
|
||||
if ( amfMaterials[ volume.materialId ] !== undefined ) {
|
||||
|
||||
material = amfMaterials[ volume.materialId ];
|
||||
|
||||
}
|
||||
|
||||
newGeometry.scale( amfScale, amfScale, amfScale );
|
||||
newObject.add( new Mesh( newGeometry, material.clone() ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sceneObject.add( newObject );
|
||||
|
||||
}
|
||||
|
||||
return sceneObject;
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
export { AMFLoader };
|
||||
2307
libs/three.js/loaders/AssimpLoader.js
Normal file
2307
libs/three.js/loaders/AssimpLoader.js
Normal file
File diff suppressed because it is too large
Load Diff
439
libs/three.js/loaders/BVHLoader.js
Normal file
439
libs/three.js/loaders/BVHLoader.js
Normal file
@ -0,0 +1,439 @@
|
||||
import {
|
||||
AnimationClip,
|
||||
Bone,
|
||||
FileLoader,
|
||||
Loader,
|
||||
Quaternion,
|
||||
QuaternionKeyframeTrack,
|
||||
Skeleton,
|
||||
Vector3,
|
||||
VectorKeyframeTrack
|
||||
} from '../../../build/three.module.js';
|
||||
|
||||
/**
|
||||
* Description: reads BVH files and outputs a single Skeleton and an AnimationClip
|
||||
*
|
||||
* Currently only supports bvh files containing a single root.
|
||||
*
|
||||
*/
|
||||
|
||||
var BVHLoader = function ( manager ) {
|
||||
|
||||
Loader.call( this, manager );
|
||||
|
||||
this.animateBonePositions = true;
|
||||
this.animateBoneRotations = true;
|
||||
|
||||
};
|
||||
|
||||
BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
|
||||
|
||||
constructor: BVHLoader,
|
||||
|
||||
load: function ( url, onLoad, onProgress, onError ) {
|
||||
|
||||
var scope = this;
|
||||
|
||||
var loader = new FileLoader( scope.manager );
|
||||
loader.setPath( scope.path );
|
||||
loader.setRequestHeader( scope.requestHeader );
|
||||
loader.setWithCredentials( scope.withCredentials );
|
||||
loader.load( url, function ( text ) {
|
||||
|
||||
try {
|
||||
|
||||
onLoad( scope.parse( text ) );
|
||||
|
||||
} catch ( e ) {
|
||||
|
||||
if ( onError ) {
|
||||
|
||||
onError( e );
|
||||
|
||||
} else {
|
||||
|
||||
console.error( e );
|
||||
|
||||
}
|
||||
|
||||
scope.manager.itemError( url );
|
||||
|
||||
}
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
},
|
||||
|
||||
parse: function ( text ) {
|
||||
|
||||
/*
|
||||
reads a string array (lines) from a BVH file
|
||||
and outputs a skeleton structure including motion data
|
||||
|
||||
returns thee root node:
|
||||
{ name: '', channels: [], children: [] }
|
||||
*/
|
||||
function readBvh( lines ) {
|
||||
|
||||
// read model structure
|
||||
|
||||
if ( nextLine( lines ) !== 'HIERARCHY' ) {
|
||||
|
||||
console.error( 'THREE.BVHLoader: HIERARCHY expected.' );
|
||||
|
||||
}
|
||||
|
||||
var list = []; // collects flat array of all bones
|
||||
var root = readNode( lines, nextLine( lines ), list );
|
||||
|
||||
// read motion data
|
||||
|
||||
if ( nextLine( lines ) !== 'MOTION' ) {
|
||||
|
||||
console.error( 'THREE.BVHLoader: MOTION expected.' );
|
||||
|
||||
}
|
||||
|
||||
// number of frames
|
||||
|
||||
var tokens = nextLine( lines ).split( /[\s]+/ );
|
||||
var numFrames = parseInt( tokens[ 1 ] );
|
||||
|
||||
if ( isNaN( numFrames ) ) {
|
||||
|
||||
console.error( 'THREE.BVHLoader: Failed to read number of frames.' );
|
||||
|
||||
}
|
||||
|
||||
// frame time
|
||||
|
||||
tokens = nextLine( lines ).split( /[\s]+/ );
|
||||
var frameTime = parseFloat( tokens[ 2 ] );
|
||||
|
||||
if ( isNaN( frameTime ) ) {
|
||||
|
||||
console.error( 'THREE.BVHLoader: Failed to read frame time.' );
|
||||
|
||||
}
|
||||
|
||||
// read frame data line by line
|
||||
|
||||
for ( var i = 0; i < numFrames; i ++ ) {
|
||||
|
||||
tokens = nextLine( lines ).split( /[\s]+/ );
|
||||
readFrameData( tokens, i * frameTime, root );
|
||||
|
||||
}
|
||||
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Recursively reads data from a single frame into the bone hierarchy.
|
||||
The passed bone hierarchy has to be structured in the same order as the BVH file.
|
||||
keyframe data is stored in bone.frames.
|
||||
|
||||
- data: splitted string array (frame values), values are shift()ed so
|
||||
this should be empty after parsing the whole hierarchy.
|
||||
- frameTime: playback time for this keyframe.
|
||||
- bone: the bone to read frame data from.
|
||||
*/
|
||||
function readFrameData( data, frameTime, bone ) {
|
||||
|
||||
// end sites have no motion data
|
||||
|
||||
if ( bone.type === 'ENDSITE' ) return;
|
||||
|
||||
// add keyframe
|
||||
|
||||
var keyframe = {
|
||||
time: frameTime,
|
||||
position: new Vector3(),
|
||||
rotation: new Quaternion()
|
||||
};
|
||||
|
||||
bone.frames.push( keyframe );
|
||||
|
||||
var quat = new Quaternion();
|
||||
|
||||
var vx = new Vector3( 1, 0, 0 );
|
||||
var vy = new Vector3( 0, 1, 0 );
|
||||
var vz = new Vector3( 0, 0, 1 );
|
||||
|
||||
// parse values for each channel in node
|
||||
|
||||
for ( var i = 0; i < bone.channels.length; i ++ ) {
|
||||
|
||||
switch ( bone.channels[ i ] ) {
|
||||
|
||||
case 'Xposition':
|
||||
keyframe.position.x = parseFloat( data.shift().trim() );
|
||||
break;
|
||||
case 'Yposition':
|
||||
keyframe.position.y = parseFloat( data.shift().trim() );
|
||||
break;
|
||||
case 'Zposition':
|
||||
keyframe.position.z = parseFloat( data.shift().trim() );
|
||||
break;
|
||||
case 'Xrotation':
|
||||
quat.setFromAxisAngle( vx, parseFloat( data.shift().trim() ) * Math.PI / 180 );
|
||||
keyframe.rotation.multiply( quat );
|
||||
break;
|
||||
case 'Yrotation':
|
||||
quat.setFromAxisAngle( vy, parseFloat( data.shift().trim() ) * Math.PI / 180 );
|
||||
keyframe.rotation.multiply( quat );
|
||||
break;
|
||||
case 'Zrotation':
|
||||
quat.setFromAxisAngle( vz, parseFloat( data.shift().trim() ) * Math.PI / 180 );
|
||||
keyframe.rotation.multiply( quat );
|
||||
break;
|
||||
default:
|
||||
console.warn( 'THREE.BVHLoader: Invalid channel type.' );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// parse child nodes
|
||||
|
||||
for ( var i = 0; i < bone.children.length; i ++ ) {
|
||||
|
||||
readFrameData( data, frameTime, bone.children[ i ] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Recursively parses the HIERACHY section of the BVH file
|
||||
|
||||
- lines: all lines of the file. lines are consumed as we go along.
|
||||
- firstline: line containing the node type and name e.g. 'JOINT hip'
|
||||
- list: collects a flat list of nodes
|
||||
|
||||
returns: a BVH node including children
|
||||
*/
|
||||
function readNode( lines, firstline, list ) {
|
||||
|
||||
var node = { name: '', type: '', frames: [] };
|
||||
list.push( node );
|
||||
|
||||
// parse node type and name
|
||||
|
||||
var tokens = firstline.split( /[\s]+/ );
|
||||
|
||||
if ( tokens[ 0 ].toUpperCase() === 'END' && tokens[ 1 ].toUpperCase() === 'SITE' ) {
|
||||
|
||||
node.type = 'ENDSITE';
|
||||
node.name = 'ENDSITE'; // bvh end sites have no name
|
||||
|
||||
} else {
|
||||
|
||||
node.name = tokens[ 1 ];
|
||||
node.type = tokens[ 0 ].toUpperCase();
|
||||
|
||||
}
|
||||
|
||||
if ( nextLine( lines ) !== '{' ) {
|
||||
|
||||
console.error( 'THREE.BVHLoader: Expected opening { after type & name' );
|
||||
|
||||
}
|
||||
|
||||
// parse OFFSET
|
||||
|
||||
tokens = nextLine( lines ).split( /[\s]+/ );
|
||||
|
||||
if ( tokens[ 0 ] !== 'OFFSET' ) {
|
||||
|
||||
console.error( 'THREE.BVHLoader: Expected OFFSET but got: ' + tokens[ 0 ] );
|
||||
|
||||
}
|
||||
|
||||
if ( tokens.length !== 4 ) {
|
||||
|
||||
console.error( 'THREE.BVHLoader: Invalid number of values for OFFSET.' );
|
||||
|
||||
}
|
||||
|
||||
var offset = new Vector3(
|
||||
parseFloat( tokens[ 1 ] ),
|
||||
parseFloat( tokens[ 2 ] ),
|
||||
parseFloat( tokens[ 3 ] )
|
||||
);
|
||||
|
||||
if ( isNaN( offset.x ) || isNaN( offset.y ) || isNaN( offset.z ) ) {
|
||||
|
||||
console.error( 'THREE.BVHLoader: Invalid values of OFFSET.' );
|
||||
|
||||
}
|
||||
|
||||
node.offset = offset;
|
||||
|
||||
// parse CHANNELS definitions
|
||||
|
||||
if ( node.type !== 'ENDSITE' ) {
|
||||
|
||||
tokens = nextLine( lines ).split( /[\s]+/ );
|
||||
|
||||
if ( tokens[ 0 ] !== 'CHANNELS' ) {
|
||||
|
||||
console.error( 'THREE.BVHLoader: Expected CHANNELS definition.' );
|
||||
|
||||
}
|
||||
|
||||
var numChannels = parseInt( tokens[ 1 ] );
|
||||
node.channels = tokens.splice( 2, numChannels );
|
||||
node.children = [];
|
||||
|
||||
}
|
||||
|
||||
// read children
|
||||
|
||||
while ( true ) {
|
||||
|
||||
var line = nextLine( lines );
|
||||
|
||||
if ( line === '}' ) {
|
||||
|
||||
return node;
|
||||
|
||||
} else {
|
||||
|
||||
node.children.push( readNode( lines, line, list ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
recursively converts the internal bvh node structure to a Bone hierarchy
|
||||
|
||||
source: the bvh root node
|
||||
list: pass an empty array, collects a flat list of all converted THREE.Bones
|
||||
|
||||
returns the root Bone
|
||||
*/
|
||||
function toTHREEBone( source, list ) {
|
||||
|
||||
var bone = new Bone();
|
||||
list.push( bone );
|
||||
|
||||
bone.position.add( source.offset );
|
||||
bone.name = source.name;
|
||||
|
||||
if ( source.type !== 'ENDSITE' ) {
|
||||
|
||||
for ( var i = 0; i < source.children.length; i ++ ) {
|
||||
|
||||
bone.add( toTHREEBone( source.children[ i ], list ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return bone;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
builds a AnimationClip from the keyframe data saved in each bone.
|
||||
|
||||
bone: bvh root node
|
||||
|
||||
returns: a AnimationClip containing position and quaternion tracks
|
||||
*/
|
||||
function toTHREEAnimation( bones ) {
|
||||
|
||||
var tracks = [];
|
||||
|
||||
// create a position and quaternion animation track for each node
|
||||
|
||||
for ( var i = 0; i < bones.length; i ++ ) {
|
||||
|
||||
var bone = bones[ i ];
|
||||
|
||||
if ( bone.type === 'ENDSITE' )
|
||||
continue;
|
||||
|
||||
// track data
|
||||
|
||||
var times = [];
|
||||
var positions = [];
|
||||
var rotations = [];
|
||||
|
||||
for ( var j = 0; j < bone.frames.length; j ++ ) {
|
||||
|
||||
var frame = bone.frames[ j ];
|
||||
|
||||
times.push( frame.time );
|
||||
|
||||
// the animation system animates the position property,
|
||||
// so we have to add the joint offset to all values
|
||||
|
||||
positions.push( frame.position.x + bone.offset.x );
|
||||
positions.push( frame.position.y + bone.offset.y );
|
||||
positions.push( frame.position.z + bone.offset.z );
|
||||
|
||||
rotations.push( frame.rotation.x );
|
||||
rotations.push( frame.rotation.y );
|
||||
rotations.push( frame.rotation.z );
|
||||
rotations.push( frame.rotation.w );
|
||||
|
||||
}
|
||||
|
||||
if ( scope.animateBonePositions ) {
|
||||
|
||||
tracks.push( new VectorKeyframeTrack( '.bones[' + bone.name + '].position', times, positions ) );
|
||||
|
||||
}
|
||||
|
||||
if ( scope.animateBoneRotations ) {
|
||||
|
||||
tracks.push( new QuaternionKeyframeTrack( '.bones[' + bone.name + '].quaternion', times, rotations ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new AnimationClip( 'animation', - 1, tracks );
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
returns the next non-empty line in lines
|
||||
*/
|
||||
function nextLine( lines ) {
|
||||
|
||||
var line;
|
||||
// skip empty lines
|
||||
while ( ( line = lines.shift().trim() ).length === 0 ) { }
|
||||
|
||||
return line;
|
||||
|
||||
}
|
||||
|
||||
var scope = this;
|
||||
|
||||
var lines = text.split( /[\r\n]+/g );
|
||||
|
||||
var bones = readBvh( lines );
|
||||
|
||||
var threeBones = [];
|
||||
toTHREEBone( bones[ 0 ], threeBones );
|
||||
|
||||
var threeClip = toTHREEAnimation( bones );
|
||||
|
||||
return {
|
||||
skeleton: new Skeleton( threeBones ),
|
||||
clip: threeClip
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
export { BVHLoader };
|
||||
547
libs/three.js/loaders/BasisTextureLoader.js
Normal file
547
libs/three.js/loaders/BasisTextureLoader.js
Normal file
@ -0,0 +1,547 @@
|
||||
import {
|
||||
CompressedTexture,
|
||||
FileLoader,
|
||||
LinearFilter,
|
||||
LinearMipmapLinearFilter,
|
||||
Loader,
|
||||
RGBA_ASTC_4x4_Format,
|
||||
RGBA_BPTC_Format,
|
||||
RGBA_PVRTC_4BPPV1_Format,
|
||||
RGB_ETC1_Format,
|
||||
RGB_PVRTC_4BPPV1_Format,
|
||||
UnsignedByteType
|
||||
} from '../../../build/three.module.js';
|
||||
|
||||
/**
|
||||
* Loader for Basis Universal GPU Texture Codec.
|
||||
*
|
||||
* Basis Universal is a "supercompressed" GPU texture and texture video
|
||||
* compression system that outputs a highly compressed intermediate file format
|
||||
* (.basis) that can be quickly transcoded to a wide variety of GPU texture
|
||||
* compression formats.
|
||||
*
|
||||
* This loader parallelizes the transcoding process across a configurable number
|
||||
* of web workers, before transferring the transcoded compressed texture back
|
||||
* to the main thread.
|
||||
*/
|
||||
var BasisTextureLoader = function ( manager ) {
|
||||
|
||||
Loader.call( this, manager );
|
||||
|
||||
this.transcoderPath = '';
|
||||
this.transcoderBinary = null;
|
||||
this.transcoderPending = null;
|
||||
|
||||
this.workerLimit = 4;
|
||||
this.workerPool = [];
|
||||
this.workerNextTaskID = 1;
|
||||
this.workerSourceURL = '';
|
||||
this.workerConfig = {
|
||||
format: null,
|
||||
astcSupported: false,
|
||||
bptcSupported: false,
|
||||
etcSupported: false,
|
||||
dxtSupported: false,
|
||||
pvrtcSupported: false,
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
BasisTextureLoader.taskCache = new WeakMap();
|
||||
|
||||
BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
|
||||
|
||||
constructor: BasisTextureLoader,
|
||||
|
||||
setTranscoderPath: function ( path ) {
|
||||
|
||||
this.transcoderPath = path;
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
setWorkerLimit: function ( workerLimit ) {
|
||||
|
||||
this.workerLimit = workerLimit;
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
detectSupport: function ( renderer ) {
|
||||
|
||||
var config = this.workerConfig;
|
||||
|
||||
config.astcSupported = renderer.extensions.has( 'WEBGL_compressed_texture_astc' );
|
||||
config.bptcSupported = renderer.extensions.has( 'EXT_texture_compression_bptc' );
|
||||
config.etcSupported = renderer.extensions.has( 'WEBGL_compressed_texture_etc1' );
|
||||
config.dxtSupported = renderer.extensions.has( 'WEBGL_compressed_texture_s3tc' );
|
||||
config.pvrtcSupported = renderer.extensions.has( 'WEBGL_compressed_texture_pvrtc' )
|
||||
|| renderer.extensions.has( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );
|
||||
|
||||
if ( config.astcSupported ) {
|
||||
|
||||
config.format = BasisTextureLoader.BASIS_FORMAT.cTFASTC_4x4;
|
||||
|
||||
} else if ( config.bptcSupported ) {
|
||||
|
||||
config.format = BasisTextureLoader.BASIS_FORMAT.cTFBC7_M5;
|
||||
|
||||
} else if ( config.dxtSupported ) {
|
||||
|
||||
config.format = BasisTextureLoader.BASIS_FORMAT.cTFBC3;
|
||||
|
||||
} else if ( config.pvrtcSupported ) {
|
||||
|
||||
config.format = BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA;
|
||||
|
||||
} else if ( config.etcSupported ) {
|
||||
|
||||
config.format = BasisTextureLoader.BASIS_FORMAT.cTFETC1;
|
||||
|
||||
} else {
|
||||
|
||||
throw new Error( 'THREE.BasisTextureLoader: No suitable compressed texture format found.' );
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
load: function ( url, onLoad, onProgress, onError ) {
|
||||
|
||||
var loader = new FileLoader( this.manager );
|
||||
|
||||
loader.setResponseType( 'arraybuffer' );
|
||||
loader.setWithCredentials( this.withCredentials );
|
||||
|
||||
loader.load( url, ( buffer ) => {
|
||||
|
||||
// Check for an existing task using this buffer. A transferred buffer cannot be transferred
|
||||
// again from this thread.
|
||||
if ( BasisTextureLoader.taskCache.has( buffer ) ) {
|
||||
|
||||
var cachedTask = BasisTextureLoader.taskCache.get( buffer );
|
||||
|
||||
return cachedTask.promise.then( onLoad ).catch( onError );
|
||||
|
||||
}
|
||||
|
||||
this._createTexture( buffer, url )
|
||||
.then( onLoad )
|
||||
.catch( onError );
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {ArrayBuffer} buffer
|
||||
* @param {string} url
|
||||
* @return {Promise<CompressedTexture>}
|
||||
*/
|
||||
_createTexture: function ( buffer, url ) {
|
||||
|
||||
var worker;
|
||||
var taskID;
|
||||
|
||||
var taskCost = buffer.byteLength;
|
||||
|
||||
var texturePending = this._allocateWorker( taskCost )
|
||||
.then( ( _worker ) => {
|
||||
|
||||
worker = _worker;
|
||||
taskID = this.workerNextTaskID ++;
|
||||
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
|
||||
worker._callbacks[ taskID ] = { resolve, reject };
|
||||
|
||||
worker.postMessage( { type: 'transcode', id: taskID, buffer }, [ buffer ] );
|
||||
|
||||
} );
|
||||
|
||||
} )
|
||||
.then( ( message ) => {
|
||||
|
||||
var config = this.workerConfig;
|
||||
|
||||
var { width, height, mipmaps, format } = message;
|
||||
|
||||
var texture;
|
||||
|
||||
switch ( format ) {
|
||||
|
||||
case BasisTextureLoader.BASIS_FORMAT.cTFASTC_4x4:
|
||||
texture = new CompressedTexture( mipmaps, width, height, RGBA_ASTC_4x4_Format );
|
||||
break;
|
||||
case BasisTextureLoader.BASIS_FORMAT.cTFBC7_M5:
|
||||
texture = new CompressedTexture( mipmaps, width, height, RGBA_BPTC_Format );
|
||||
break;
|
||||
case BasisTextureLoader.BASIS_FORMAT.cTFBC1:
|
||||
case BasisTextureLoader.BASIS_FORMAT.cTFBC3:
|
||||
texture = new CompressedTexture( mipmaps, width, height, BasisTextureLoader.DXT_FORMAT_MAP[ config.format ], UnsignedByteType );
|
||||
break;
|
||||
case BasisTextureLoader.BASIS_FORMAT.cTFETC1:
|
||||
texture = new CompressedTexture( mipmaps, width, height, RGB_ETC1_Format );
|
||||
break;
|
||||
case BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB:
|
||||
texture = new CompressedTexture( mipmaps, width, height, RGB_PVRTC_4BPPV1_Format );
|
||||
break;
|
||||
case BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA:
|
||||
texture = new CompressedTexture( mipmaps, width, height, RGBA_PVRTC_4BPPV1_Format );
|
||||
break;
|
||||
default:
|
||||
throw new Error( 'THREE.BasisTextureLoader: No supported format available.' );
|
||||
|
||||
}
|
||||
|
||||
texture.minFilter = mipmaps.length === 1 ? LinearFilter : LinearMipmapLinearFilter;
|
||||
texture.magFilter = LinearFilter;
|
||||
texture.generateMipmaps = false;
|
||||
texture.needsUpdate = true;
|
||||
|
||||
return texture;
|
||||
|
||||
} );
|
||||
|
||||
// Note: replaced '.finally()' with '.catch().then()' block - iOS 11 support (#19416)
|
||||
texturePending
|
||||
.catch( () => true )
|
||||
.then( () => {
|
||||
|
||||
if ( worker && taskID ) {
|
||||
|
||||
worker._taskLoad -= taskCost;
|
||||
delete worker._callbacks[ taskID ];
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
// Cache the task result.
|
||||
BasisTextureLoader.taskCache.set( buffer, {
|
||||
|
||||
url: url,
|
||||
promise: texturePending
|
||||
|
||||
} );
|
||||
|
||||
return texturePending;
|
||||
|
||||
},
|
||||
|
||||
_initTranscoder: function () {
|
||||
|
||||
if ( ! this.transcoderPending ) {
|
||||
|
||||
// Load transcoder wrapper.
|
||||
var jsLoader = new FileLoader( this.manager );
|
||||
jsLoader.setPath( this.transcoderPath );
|
||||
jsLoader.setWithCredentials( this.withCredentials );
|
||||
var jsContent = new Promise( ( resolve, reject ) => {
|
||||
|
||||
jsLoader.load( 'basis_transcoder.js', resolve, undefined, reject );
|
||||
|
||||
} );
|
||||
|
||||
// Load transcoder WASM binary.
|
||||
var binaryLoader = new FileLoader( this.manager );
|
||||
binaryLoader.setPath( this.transcoderPath );
|
||||
binaryLoader.setResponseType( 'arraybuffer' );
|
||||
binaryLoader.setWithCredentials( this.withCredentials );
|
||||
var binaryContent = new Promise( ( resolve, reject ) => {
|
||||
|
||||
binaryLoader.load( 'basis_transcoder.wasm', resolve, undefined, reject );
|
||||
|
||||
} );
|
||||
|
||||
this.transcoderPending = Promise.all( [ jsContent, binaryContent ] )
|
||||
.then( ( [ jsContent, binaryContent ] ) => {
|
||||
|
||||
var fn = BasisTextureLoader.BasisWorker.toString();
|
||||
|
||||
var body = [
|
||||
'/* basis_transcoder.js */',
|
||||
jsContent,
|
||||
'/* worker */',
|
||||
fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) )
|
||||
].join( '\n' );
|
||||
|
||||
this.workerSourceURL = URL.createObjectURL( new Blob( [ body ] ) );
|
||||
this.transcoderBinary = binaryContent;
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
return this.transcoderPending;
|
||||
|
||||
},
|
||||
|
||||
_allocateWorker: function ( taskCost ) {
|
||||
|
||||
return this._initTranscoder().then( () => {
|
||||
|
||||
if ( this.workerPool.length < this.workerLimit ) {
|
||||
|
||||
var worker = new Worker( this.workerSourceURL );
|
||||
|
||||
worker._callbacks = {};
|
||||
worker._taskLoad = 0;
|
||||
|
||||
worker.postMessage( {
|
||||
type: 'init',
|
||||
config: this.workerConfig,
|
||||
transcoderBinary: this.transcoderBinary,
|
||||
} );
|
||||
|
||||
worker.onmessage = function ( e ) {
|
||||
|
||||
var message = e.data;
|
||||
|
||||
switch ( message.type ) {
|
||||
|
||||
case 'transcode':
|
||||
worker._callbacks[ message.id ].resolve( message );
|
||||
break;
|
||||
|
||||
case 'error':
|
||||
worker._callbacks[ message.id ].reject( message );
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error( 'THREE.BasisTextureLoader: Unexpected message, "' + message.type + '"' );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.workerPool.push( worker );
|
||||
|
||||
} else {
|
||||
|
||||
this.workerPool.sort( function ( a, b ) {
|
||||
|
||||
return a._taskLoad > b._taskLoad ? - 1 : 1;
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
var worker = this.workerPool[ this.workerPool.length - 1 ];
|
||||
|
||||
worker._taskLoad += taskCost;
|
||||
|
||||
return worker;
|
||||
|
||||
} );
|
||||
|
||||
},
|
||||
|
||||
dispose: function () {
|
||||
|
||||
for ( var i = 0; i < this.workerPool.length; i ++ ) {
|
||||
|
||||
this.workerPool[ i ].terminate();
|
||||
|
||||
}
|
||||
|
||||
this.workerPool.length = 0;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
/* CONSTANTS */
|
||||
|
||||
BasisTextureLoader.BASIS_FORMAT = {
|
||||
cTFETC1: 0,
|
||||
cTFETC2: 1,
|
||||
cTFBC1: 2,
|
||||
cTFBC3: 3,
|
||||
cTFBC4: 4,
|
||||
cTFBC5: 5,
|
||||
cTFBC7_M6_OPAQUE_ONLY: 6,
|
||||
cTFBC7_M5: 7,
|
||||
cTFPVRTC1_4_RGB: 8,
|
||||
cTFPVRTC1_4_RGBA: 9,
|
||||
cTFASTC_4x4: 10,
|
||||
cTFATC_RGB: 11,
|
||||
cTFATC_RGBA_INTERPOLATED_ALPHA: 12,
|
||||
cTFRGBA32: 13,
|
||||
cTFRGB565: 14,
|
||||
cTFBGR565: 15,
|
||||
cTFRGBA4444: 16,
|
||||
};
|
||||
|
||||
// DXT formats, from:
|
||||
// http://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_s3tc/
|
||||
BasisTextureLoader.DXT_FORMAT = {
|
||||
COMPRESSED_RGB_S3TC_DXT1_EXT: 0x83F0,
|
||||
COMPRESSED_RGBA_S3TC_DXT1_EXT: 0x83F1,
|
||||
COMPRESSED_RGBA_S3TC_DXT3_EXT: 0x83F2,
|
||||
COMPRESSED_RGBA_S3TC_DXT5_EXT: 0x83F3,
|
||||
};
|
||||
BasisTextureLoader.DXT_FORMAT_MAP = {};
|
||||
BasisTextureLoader.DXT_FORMAT_MAP[ BasisTextureLoader.BASIS_FORMAT.cTFBC1 ] =
|
||||
BasisTextureLoader.DXT_FORMAT.COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||
BasisTextureLoader.DXT_FORMAT_MAP[ BasisTextureLoader.BASIS_FORMAT.cTFBC3 ] =
|
||||
BasisTextureLoader.DXT_FORMAT.COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
|
||||
/* WEB WORKER */
|
||||
|
||||
BasisTextureLoader.BasisWorker = function () {
|
||||
|
||||
var config;
|
||||
var transcoderPending;
|
||||
var _BasisFile;
|
||||
|
||||
onmessage = function ( e ) {
|
||||
|
||||
var message = e.data;
|
||||
|
||||
switch ( message.type ) {
|
||||
|
||||
case 'init':
|
||||
config = message.config;
|
||||
init( message.transcoderBinary );
|
||||
break;
|
||||
|
||||
case 'transcode':
|
||||
transcoderPending.then( () => {
|
||||
|
||||
try {
|
||||
|
||||
var { width, height, hasAlpha, mipmaps, format } = transcode( message.buffer );
|
||||
|
||||
var buffers = [];
|
||||
|
||||
for ( var i = 0; i < mipmaps.length; ++ i ) {
|
||||
|
||||
buffers.push( mipmaps[ i ].data.buffer );
|
||||
|
||||
}
|
||||
|
||||
self.postMessage( { type: 'transcode', id: message.id, width, height, hasAlpha, mipmaps, format }, buffers );
|
||||
|
||||
} catch ( error ) {
|
||||
|
||||
console.error( error );
|
||||
|
||||
self.postMessage( { type: 'error', id: message.id, error: error.message } );
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function init( wasmBinary ) {
|
||||
|
||||
var BasisModule;
|
||||
transcoderPending = new Promise( ( resolve ) => {
|
||||
|
||||
BasisModule = { wasmBinary, onRuntimeInitialized: resolve };
|
||||
BASIS( BasisModule ); // eslint-disable-line no-undef
|
||||
|
||||
} ).then( () => {
|
||||
|
||||
var { BasisFile, initializeBasis } = BasisModule;
|
||||
|
||||
_BasisFile = BasisFile;
|
||||
|
||||
initializeBasis();
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
function transcode( buffer ) {
|
||||
|
||||
var basisFile = new _BasisFile( new Uint8Array( buffer ) );
|
||||
|
||||
var width = basisFile.getImageWidth( 0, 0 );
|
||||
var height = basisFile.getImageHeight( 0, 0 );
|
||||
var levels = basisFile.getNumLevels( 0 );
|
||||
var hasAlpha = basisFile.getHasAlpha();
|
||||
|
||||
function cleanup() {
|
||||
|
||||
basisFile.close();
|
||||
basisFile.delete();
|
||||
|
||||
}
|
||||
|
||||
if ( ! hasAlpha ) {
|
||||
|
||||
switch ( config.format ) {
|
||||
|
||||
case 9: // Hardcoded: BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA
|
||||
config.format = 8; // Hardcoded: BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! width || ! height || ! levels ) {
|
||||
|
||||
cleanup();
|
||||
throw new Error( 'THREE.BasisTextureLoader: Invalid .basis file' );
|
||||
|
||||
}
|
||||
|
||||
if ( ! basisFile.startTranscoding() ) {
|
||||
|
||||
cleanup();
|
||||
throw new Error( 'THREE.BasisTextureLoader: .startTranscoding failed' );
|
||||
|
||||
}
|
||||
|
||||
var mipmaps = [];
|
||||
|
||||
for ( var mip = 0; mip < levels; mip ++ ) {
|
||||
|
||||
var mipWidth = basisFile.getImageWidth( 0, mip );
|
||||
var mipHeight = basisFile.getImageHeight( 0, mip );
|
||||
var dst = new Uint8Array( basisFile.getImageTranscodedSizeInBytes( 0, mip, config.format ) );
|
||||
|
||||
var status = basisFile.transcodeImage(
|
||||
dst,
|
||||
0,
|
||||
mip,
|
||||
config.format,
|
||||
0,
|
||||
hasAlpha
|
||||
);
|
||||
|
||||
if ( ! status ) {
|
||||
|
||||
cleanup();
|
||||
throw new Error( 'THREE.BasisTextureLoader: .transcodeImage failed.' );
|
||||
|
||||
}
|
||||
|
||||
mipmaps.push( { data: dst, width: mipWidth, height: mipHeight } );
|
||||
|
||||
}
|
||||
|
||||
cleanup();
|
||||
|
||||
return { width, height, hasAlpha, mipmaps, format: config.format };
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export { BasisTextureLoader };
|
||||
4024
libs/three.js/loaders/ColladaLoader.js
Normal file
4024
libs/three.js/loaders/ColladaLoader.js
Normal file
File diff suppressed because it is too large
Load Diff
281
libs/three.js/loaders/DDSLoader.js
Normal file
281
libs/three.js/loaders/DDSLoader.js
Normal file
@ -0,0 +1,281 @@
|
||||
import {
|
||||
CompressedTextureLoader,
|
||||
RGBAFormat,
|
||||
RGBA_S3TC_DXT3_Format,
|
||||
RGBA_S3TC_DXT5_Format,
|
||||
RGB_ETC1_Format,
|
||||
RGB_S3TC_DXT1_Format
|
||||
} from '../../../build/three.module.js';
|
||||
|
||||
var DDSLoader = function ( manager ) {
|
||||
|
||||
CompressedTextureLoader.call( this, manager );
|
||||
|
||||
};
|
||||
|
||||
DDSLoader.prototype = Object.assign( Object.create( CompressedTextureLoader.prototype ), {
|
||||
|
||||
constructor: DDSLoader,
|
||||
|
||||
parse: function ( buffer, loadMipmaps ) {
|
||||
|
||||
var dds = { mipmaps: [], width: 0, height: 0, format: null, mipmapCount: 1 };
|
||||
|
||||
// Adapted from @toji's DDS utils
|
||||
// https://github.com/toji/webgl-texture-utils/blob/master/texture-util/dds.js
|
||||
|
||||
// All values and structures referenced from:
|
||||
// http://msdn.microsoft.com/en-us/library/bb943991.aspx/
|
||||
|
||||
var DDS_MAGIC = 0x20534444;
|
||||
|
||||
// var DDSD_CAPS = 0x1;
|
||||
// var DDSD_HEIGHT = 0x2;
|
||||
// var DDSD_WIDTH = 0x4;
|
||||
// var DDSD_PITCH = 0x8;
|
||||
// var DDSD_PIXELFORMAT = 0x1000;
|
||||
var DDSD_MIPMAPCOUNT = 0x20000;
|
||||
// var DDSD_LINEARSIZE = 0x80000;
|
||||
// var DDSD_DEPTH = 0x800000;
|
||||
|
||||
// var DDSCAPS_COMPLEX = 0x8;
|
||||
// var DDSCAPS_MIPMAP = 0x400000;
|
||||
// var DDSCAPS_TEXTURE = 0x1000;
|
||||
|
||||
var DDSCAPS2_CUBEMAP = 0x200;
|
||||
var DDSCAPS2_CUBEMAP_POSITIVEX = 0x400;
|
||||
var DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800;
|
||||
var DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000;
|
||||
var DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000;
|
||||
var DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000;
|
||||
var DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000;
|
||||
// var DDSCAPS2_VOLUME = 0x200000;
|
||||
|
||||
// var DDPF_ALPHAPIXELS = 0x1;
|
||||
// var DDPF_ALPHA = 0x2;
|
||||
var DDPF_FOURCC = 0x4;
|
||||
// var DDPF_RGB = 0x40;
|
||||
// var DDPF_YUV = 0x200;
|
||||
// var DDPF_LUMINANCE = 0x20000;
|
||||
|
||||
function fourCCToInt32( value ) {
|
||||
|
||||
return value.charCodeAt( 0 ) +
|
||||
( value.charCodeAt( 1 ) << 8 ) +
|
||||
( value.charCodeAt( 2 ) << 16 ) +
|
||||
( value.charCodeAt( 3 ) << 24 );
|
||||
|
||||
}
|
||||
|
||||
function int32ToFourCC( value ) {
|
||||
|
||||
return String.fromCharCode(
|
||||
value & 0xff,
|
||||
( value >> 8 ) & 0xff,
|
||||
( value >> 16 ) & 0xff,
|
||||
( value >> 24 ) & 0xff
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function loadARGBMip( buffer, dataOffset, width, height ) {
|
||||
|
||||
var dataLength = width * height * 4;
|
||||
var srcBuffer = new Uint8Array( buffer, dataOffset, dataLength );
|
||||
var byteArray = new Uint8Array( dataLength );
|
||||
var dst = 0;
|
||||
var src = 0;
|
||||
for ( var y = 0; y < height; y ++ ) {
|
||||
|
||||
for ( var x = 0; x < width; x ++ ) {
|
||||
|
||||
var b = srcBuffer[ src ]; src ++;
|
||||
var g = srcBuffer[ src ]; src ++;
|
||||
var r = srcBuffer[ src ]; src ++;
|
||||
var a = srcBuffer[ src ]; src ++;
|
||||
byteArray[ dst ] = r; dst ++; //r
|
||||
byteArray[ dst ] = g; dst ++; //g
|
||||
byteArray[ dst ] = b; dst ++; //b
|
||||
byteArray[ dst ] = a; dst ++; //a
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return byteArray;
|
||||
|
||||
}
|
||||
|
||||
var FOURCC_DXT1 = fourCCToInt32( 'DXT1' );
|
||||
var FOURCC_DXT3 = fourCCToInt32( 'DXT3' );
|
||||
var FOURCC_DXT5 = fourCCToInt32( 'DXT5' );
|
||||
var FOURCC_ETC1 = fourCCToInt32( 'ETC1' );
|
||||
|
||||
var headerLengthInt = 31; // The header length in 32 bit ints
|
||||
|
||||
// Offsets into the header array
|
||||
|
||||
var off_magic = 0;
|
||||
|
||||
var off_size = 1;
|
||||
var off_flags = 2;
|
||||
var off_height = 3;
|
||||
var off_width = 4;
|
||||
|
||||
var off_mipmapCount = 7;
|
||||
|
||||
var off_pfFlags = 20;
|
||||
var off_pfFourCC = 21;
|
||||
var off_RGBBitCount = 22;
|
||||
var off_RBitMask = 23;
|
||||
var off_GBitMask = 24;
|
||||
var off_BBitMask = 25;
|
||||
var off_ABitMask = 26;
|
||||
|
||||
// var off_caps = 27;
|
||||
var off_caps2 = 28;
|
||||
// var off_caps3 = 29;
|
||||
// var off_caps4 = 30;
|
||||
|
||||
// Parse header
|
||||
|
||||
var header = new Int32Array( buffer, 0, headerLengthInt );
|
||||
|
||||
if ( header[ off_magic ] !== DDS_MAGIC ) {
|
||||
|
||||
console.error( 'THREE.DDSLoader.parse: Invalid magic number in DDS header.' );
|
||||
return dds;
|
||||
|
||||
}
|
||||
|
||||
if ( ! header[ off_pfFlags ] & DDPF_FOURCC ) {
|
||||
|
||||
console.error( 'THREE.DDSLoader.parse: Unsupported format, must contain a FourCC code.' );
|
||||
return dds;
|
||||
|
||||
}
|
||||
|
||||
var blockBytes;
|
||||
|
||||
var fourCC = header[ off_pfFourCC ];
|
||||
|
||||
var isRGBAUncompressed = false;
|
||||
|
||||
switch ( fourCC ) {
|
||||
|
||||
case FOURCC_DXT1:
|
||||
|
||||
blockBytes = 8;
|
||||
dds.format = RGB_S3TC_DXT1_Format;
|
||||
break;
|
||||
|
||||
case FOURCC_DXT3:
|
||||
|
||||
blockBytes = 16;
|
||||
dds.format = RGBA_S3TC_DXT3_Format;
|
||||
break;
|
||||
|
||||
case FOURCC_DXT5:
|
||||
|
||||
blockBytes = 16;
|
||||
dds.format = RGBA_S3TC_DXT5_Format;
|
||||
break;
|
||||
|
||||
case FOURCC_ETC1:
|
||||
|
||||
blockBytes = 8;
|
||||
dds.format = RGB_ETC1_Format;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
if ( header[ off_RGBBitCount ] === 32
|
||||
&& header[ off_RBitMask ] & 0xff0000
|
||||
&& header[ off_GBitMask ] & 0xff00
|
||||
&& header[ off_BBitMask ] & 0xff
|
||||
&& header[ off_ABitMask ] & 0xff000000 ) {
|
||||
|
||||
isRGBAUncompressed = true;
|
||||
blockBytes = 64;
|
||||
dds.format = RGBAFormat;
|
||||
|
||||
} else {
|
||||
|
||||
console.error( 'THREE.DDSLoader.parse: Unsupported FourCC code ', int32ToFourCC( fourCC ) );
|
||||
return dds;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dds.mipmapCount = 1;
|
||||
|
||||
if ( header[ off_flags ] & DDSD_MIPMAPCOUNT && loadMipmaps !== false ) {
|
||||
|
||||
dds.mipmapCount = Math.max( 1, header[ off_mipmapCount ] );
|
||||
|
||||
}
|
||||
|
||||
var caps2 = header[ off_caps2 ];
|
||||
dds.isCubemap = caps2 & DDSCAPS2_CUBEMAP ? true : false;
|
||||
if ( dds.isCubemap && (
|
||||
! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEX ) ||
|
||||
! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX ) ||
|
||||
! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEY ) ||
|
||||
! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY ) ||
|
||||
! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ ) ||
|
||||
! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ )
|
||||
) ) {
|
||||
|
||||
console.error( 'THREE.DDSLoader.parse: Incomplete cubemap faces' );
|
||||
return dds;
|
||||
|
||||
}
|
||||
|
||||
dds.width = header[ off_width ];
|
||||
dds.height = header[ off_height ];
|
||||
|
||||
var dataOffset = header[ off_size ] + 4;
|
||||
|
||||
// Extract mipmaps buffers
|
||||
|
||||
var faces = dds.isCubemap ? 6 : 1;
|
||||
|
||||
for ( var face = 0; face < faces; face ++ ) {
|
||||
|
||||
var width = dds.width;
|
||||
var height = dds.height;
|
||||
|
||||
for ( var i = 0; i < dds.mipmapCount; i ++ ) {
|
||||
|
||||
if ( isRGBAUncompressed ) {
|
||||
|
||||
var byteArray = loadARGBMip( buffer, dataOffset, width, height );
|
||||
var dataLength = byteArray.length;
|
||||
|
||||
} else {
|
||||
|
||||
var dataLength = Math.max( 4, width ) / 4 * Math.max( 4, height ) / 4 * blockBytes;
|
||||
var byteArray = new Uint8Array( buffer, dataOffset, dataLength );
|
||||
|
||||
}
|
||||
|
||||
var mipmap = { 'data': byteArray, 'width': width, 'height': height };
|
||||
dds.mipmaps.push( mipmap );
|
||||
|
||||
dataOffset += dataLength;
|
||||
|
||||
width = Math.max( width >> 1, 1 );
|
||||
height = Math.max( height >> 1, 1 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return dds;
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
export { DDSLoader };
|
||||
640
libs/three.js/loaders/DRACOLoader.js
Normal file
640
libs/three.js/loaders/DRACOLoader.js
Normal file
@ -0,0 +1,640 @@
|
||||
import {
|
||||
BufferAttribute,
|
||||
BufferGeometry,
|
||||
FileLoader,
|
||||
Loader
|
||||
} from '../../../build/three.module.js';
|
||||
|
||||
var DRACOLoader = function ( manager ) {
|
||||
|
||||
Loader.call( this, manager );
|
||||
|
||||
this.decoderPath = '';
|
||||
this.decoderConfig = {};
|
||||
this.decoderBinary = null;
|
||||
this.decoderPending = null;
|
||||
|
||||
this.workerLimit = 4;
|
||||
this.workerPool = [];
|
||||
this.workerNextTaskID = 1;
|
||||
this.workerSourceURL = '';
|
||||
|
||||
this.defaultAttributeIDs = {
|
||||
position: 'POSITION',
|
||||
normal: 'NORMAL',
|
||||
color: 'COLOR',
|
||||
uv: 'TEX_COORD'
|
||||
};
|
||||
this.defaultAttributeTypes = {
|
||||
position: 'Float32Array',
|
||||
normal: 'Float32Array',
|
||||
color: 'Float32Array',
|
||||
uv: 'Float32Array'
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
DRACOLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
|
||||
|
||||
constructor: DRACOLoader,
|
||||
|
||||
setDecoderPath: function ( path ) {
|
||||
|
||||
this.decoderPath = path;
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
setDecoderConfig: function ( config ) {
|
||||
|
||||
this.decoderConfig = config;
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
setWorkerLimit: function ( workerLimit ) {
|
||||
|
||||
this.workerLimit = workerLimit;
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
/** @deprecated */
|
||||
setVerbosity: function () {
|
||||
|
||||
console.warn( 'THREE.DRACOLoader: The .setVerbosity() method has been removed.' );
|
||||
|
||||
},
|
||||
|
||||
/** @deprecated */
|
||||
setDrawMode: function () {
|
||||
|
||||
console.warn( 'THREE.DRACOLoader: The .setDrawMode() method has been removed.' );
|
||||
|
||||
},
|
||||
|
||||
/** @deprecated */
|
||||
setSkipDequantization: function () {
|
||||
|
||||
console.warn( 'THREE.DRACOLoader: The .setSkipDequantization() method has been removed.' );
|
||||
|
||||
},
|
||||
|
||||
load: function ( url, onLoad, onProgress, onError ) {
|
||||
|
||||
var loader = new FileLoader( this.manager );
|
||||
|
||||
loader.setPath( this.path );
|
||||
loader.setResponseType( 'arraybuffer' );
|
||||
loader.setRequestHeader( this.requestHeader );
|
||||
loader.setWithCredentials( this.withCredentials );
|
||||
|
||||
loader.load( url, ( buffer ) => {
|
||||
|
||||
var taskConfig = {
|
||||
attributeIDs: this.defaultAttributeIDs,
|
||||
attributeTypes: this.defaultAttributeTypes,
|
||||
useUniqueIDs: false
|
||||
};
|
||||
|
||||
this.decodeGeometry( buffer, taskConfig )
|
||||
.then( onLoad )
|
||||
.catch( onError );
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
},
|
||||
|
||||
/** @deprecated Kept for backward-compatibility with previous DRACOLoader versions. */
|
||||
decodeDracoFile: function ( buffer, callback, attributeIDs, attributeTypes ) {
|
||||
|
||||
var taskConfig = {
|
||||
attributeIDs: attributeIDs || this.defaultAttributeIDs,
|
||||
attributeTypes: attributeTypes || this.defaultAttributeTypes,
|
||||
useUniqueIDs: !! attributeIDs
|
||||
};
|
||||
|
||||
this.decodeGeometry( buffer, taskConfig ).then( callback );
|
||||
|
||||
},
|
||||
|
||||
decodeGeometry: function ( buffer, taskConfig ) {
|
||||
|
||||
// TODO: For backward-compatibility, support 'attributeTypes' objects containing
|
||||
// references (rather than names) to typed array constructors. These must be
|
||||
// serialized before sending them to the worker.
|
||||
for ( var attribute in taskConfig.attributeTypes ) {
|
||||
|
||||
var type = taskConfig.attributeTypes[ attribute ];
|
||||
|
||||
if ( type.BYTES_PER_ELEMENT !== undefined ) {
|
||||
|
||||
taskConfig.attributeTypes[ attribute ] = type.name;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
var taskKey = JSON.stringify( taskConfig );
|
||||
|
||||
// Check for an existing task using this buffer. A transferred buffer cannot be transferred
|
||||
// again from this thread.
|
||||
if ( DRACOLoader.taskCache.has( buffer ) ) {
|
||||
|
||||
var cachedTask = DRACOLoader.taskCache.get( buffer );
|
||||
|
||||
if ( cachedTask.key === taskKey ) {
|
||||
|
||||
return cachedTask.promise;
|
||||
|
||||
} else if ( buffer.byteLength === 0 ) {
|
||||
|
||||
// Technically, it would be possible to wait for the previous task to complete,
|
||||
// transfer the buffer back, and decode again with the second configuration. That
|
||||
// is complex, and I don't know of any reason to decode a Draco buffer twice in
|
||||
// different ways, so this is left unimplemented.
|
||||
throw new Error(
|
||||
|
||||
'THREE.DRACOLoader: Unable to re-decode a buffer with different ' +
|
||||
'settings. Buffer has already been transferred.'
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
var worker;
|
||||
var taskID = this.workerNextTaskID ++;
|
||||
var taskCost = buffer.byteLength;
|
||||
|
||||
// Obtain a worker and assign a task, and construct a geometry instance
|
||||
// when the task completes.
|
||||
var geometryPending = this._getWorker( taskID, taskCost )
|
||||
.then( ( _worker ) => {
|
||||
|
||||
worker = _worker;
|
||||
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
|
||||
worker._callbacks[ taskID ] = { resolve, reject };
|
||||
|
||||
worker.postMessage( { type: 'decode', id: taskID, taskConfig, buffer }, [ buffer ] );
|
||||
|
||||
// this.debug();
|
||||
|
||||
} );
|
||||
|
||||
} )
|
||||
.then( ( message ) => this._createGeometry( message.geometry ) );
|
||||
|
||||
// Remove task from the task list.
|
||||
// Note: replaced '.finally()' with '.catch().then()' block - iOS 11 support (#19416)
|
||||
geometryPending
|
||||
.catch( () => true )
|
||||
.then( () => {
|
||||
|
||||
if ( worker && taskID ) {
|
||||
|
||||
this._releaseTask( worker, taskID );
|
||||
|
||||
// this.debug();
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
// Cache the task result.
|
||||
DRACOLoader.taskCache.set( buffer, {
|
||||
|
||||
key: taskKey,
|
||||
promise: geometryPending
|
||||
|
||||
} );
|
||||
|
||||
return geometryPending;
|
||||
|
||||
},
|
||||
|
||||
_createGeometry: function ( geometryData ) {
|
||||
|
||||
var geometry = new BufferGeometry();
|
||||
|
||||
if ( geometryData.index ) {
|
||||
|
||||
geometry.setIndex( new BufferAttribute( geometryData.index.array, 1 ) );
|
||||
|
||||
}
|
||||
|
||||
for ( var i = 0; i < geometryData.attributes.length; i ++ ) {
|
||||
|
||||
var attribute = geometryData.attributes[ i ];
|
||||
var name = attribute.name;
|
||||
var array = attribute.array;
|
||||
var itemSize = attribute.itemSize;
|
||||
|
||||
geometry.setAttribute( name, new BufferAttribute( array, itemSize ) );
|
||||
|
||||
}
|
||||
|
||||
return geometry;
|
||||
|
||||
},
|
||||
|
||||
_loadLibrary: function ( url, responseType ) {
|
||||
|
||||
var loader = new FileLoader( this.manager );
|
||||
loader.setPath( this.decoderPath );
|
||||
loader.setResponseType( responseType );
|
||||
loader.setWithCredentials( this.withCredentials );
|
||||
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
|
||||
loader.load( url, resolve, undefined, reject );
|
||||
|
||||
} );
|
||||
|
||||
},
|
||||
|
||||
preload: function () {
|
||||
|
||||
this._initDecoder();
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
_initDecoder: function () {
|
||||
|
||||
if ( this.decoderPending ) return this.decoderPending;
|
||||
|
||||
var useJS = typeof WebAssembly !== 'object' || this.decoderConfig.type === 'js';
|
||||
var librariesPending = [];
|
||||
|
||||
if ( useJS ) {
|
||||
|
||||
librariesPending.push( this._loadLibrary( 'draco_decoder.js', 'text' ) );
|
||||
|
||||
} else {
|
||||
|
||||
librariesPending.push( this._loadLibrary( 'draco_wasm_wrapper.js', 'text' ) );
|
||||
librariesPending.push( this._loadLibrary( 'draco_decoder.wasm', 'arraybuffer' ) );
|
||||
|
||||
}
|
||||
|
||||
this.decoderPending = Promise.all( librariesPending )
|
||||
.then( ( libraries ) => {
|
||||
|
||||
var jsContent = libraries[ 0 ];
|
||||
|
||||
if ( ! useJS ) {
|
||||
|
||||
this.decoderConfig.wasmBinary = libraries[ 1 ];
|
||||
|
||||
}
|
||||
|
||||
var fn = DRACOLoader.DRACOWorker.toString();
|
||||
|
||||
var body = [
|
||||
'/* draco decoder */',
|
||||
jsContent,
|
||||
'',
|
||||
'/* worker */',
|
||||
fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) )
|
||||
].join( '\n' );
|
||||
|
||||
this.workerSourceURL = URL.createObjectURL( new Blob( [ body ] ) );
|
||||
|
||||
} );
|
||||
|
||||
return this.decoderPending;
|
||||
|
||||
},
|
||||
|
||||
_getWorker: function ( taskID, taskCost ) {
|
||||
|
||||
return this._initDecoder().then( () => {
|
||||
|
||||
if ( this.workerPool.length < this.workerLimit ) {
|
||||
|
||||
var worker = new Worker( this.workerSourceURL );
|
||||
|
||||
worker._callbacks = {};
|
||||
worker._taskCosts = {};
|
||||
worker._taskLoad = 0;
|
||||
|
||||
worker.postMessage( { type: 'init', decoderConfig: this.decoderConfig } );
|
||||
|
||||
worker.onmessage = function ( e ) {
|
||||
|
||||
var message = e.data;
|
||||
|
||||
switch ( message.type ) {
|
||||
|
||||
case 'decode':
|
||||
worker._callbacks[ message.id ].resolve( message );
|
||||
break;
|
||||
|
||||
case 'error':
|
||||
worker._callbacks[ message.id ].reject( message );
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error( 'THREE.DRACOLoader: Unexpected message, "' + message.type + '"' );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.workerPool.push( worker );
|
||||
|
||||
} else {
|
||||
|
||||
this.workerPool.sort( function ( a, b ) {
|
||||
|
||||
return a._taskLoad > b._taskLoad ? - 1 : 1;
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
var worker = this.workerPool[ this.workerPool.length - 1 ];
|
||||
worker._taskCosts[ taskID ] = taskCost;
|
||||
worker._taskLoad += taskCost;
|
||||
return worker;
|
||||
|
||||
} );
|
||||
|
||||
},
|
||||
|
||||
_releaseTask: function ( worker, taskID ) {
|
||||
|
||||
worker._taskLoad -= worker._taskCosts[ taskID ];
|
||||
delete worker._callbacks[ taskID ];
|
||||
delete worker._taskCosts[ taskID ];
|
||||
|
||||
},
|
||||
|
||||
debug: function () {
|
||||
|
||||
console.log( 'Task load: ', this.workerPool.map( ( worker ) => worker._taskLoad ) );
|
||||
|
||||
},
|
||||
|
||||
dispose: function () {
|
||||
|
||||
for ( var i = 0; i < this.workerPool.length; ++ i ) {
|
||||
|
||||
this.workerPool[ i ].terminate();
|
||||
|
||||
}
|
||||
|
||||
this.workerPool.length = 0;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
/* WEB WORKER */
|
||||
|
||||
DRACOLoader.DRACOWorker = function () {
|
||||
|
||||
var decoderConfig;
|
||||
var decoderPending;
|
||||
|
||||
onmessage = function ( e ) {
|
||||
|
||||
var message = e.data;
|
||||
|
||||
switch ( message.type ) {
|
||||
|
||||
case 'init':
|
||||
decoderConfig = message.decoderConfig;
|
||||
decoderPending = new Promise( function ( resolve/*, reject*/ ) {
|
||||
|
||||
decoderConfig.onModuleLoaded = function ( draco ) {
|
||||
|
||||
// Module is Promise-like. Wrap before resolving to avoid loop.
|
||||
resolve( { draco: draco } );
|
||||
|
||||
};
|
||||
|
||||
DracoDecoderModule( decoderConfig ); // eslint-disable-line no-undef
|
||||
|
||||
} );
|
||||
break;
|
||||
|
||||
case 'decode':
|
||||
var buffer = message.buffer;
|
||||
var taskConfig = message.taskConfig;
|
||||
decoderPending.then( ( module ) => {
|
||||
|
||||
var draco = module.draco;
|
||||
var decoder = new draco.Decoder();
|
||||
var decoderBuffer = new draco.DecoderBuffer();
|
||||
decoderBuffer.Init( new Int8Array( buffer ), buffer.byteLength );
|
||||
|
||||
try {
|
||||
|
||||
var geometry = decodeGeometry( draco, decoder, decoderBuffer, taskConfig );
|
||||
|
||||
var buffers = geometry.attributes.map( ( attr ) => attr.array.buffer );
|
||||
|
||||
if ( geometry.index ) buffers.push( geometry.index.array.buffer );
|
||||
|
||||
self.postMessage( { type: 'decode', id: message.id, geometry }, buffers );
|
||||
|
||||
} catch ( error ) {
|
||||
|
||||
console.error( error );
|
||||
|
||||
self.postMessage( { type: 'error', id: message.id, error: error.message } );
|
||||
|
||||
} finally {
|
||||
|
||||
draco.destroy( decoderBuffer );
|
||||
draco.destroy( decoder );
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function decodeGeometry( draco, decoder, decoderBuffer, taskConfig ) {
|
||||
|
||||
var attributeIDs = taskConfig.attributeIDs;
|
||||
var attributeTypes = taskConfig.attributeTypes;
|
||||
|
||||
var dracoGeometry;
|
||||
var decodingStatus;
|
||||
|
||||
var geometryType = decoder.GetEncodedGeometryType( decoderBuffer );
|
||||
|
||||
if ( geometryType === draco.TRIANGULAR_MESH ) {
|
||||
|
||||
dracoGeometry = new draco.Mesh();
|
||||
decodingStatus = decoder.DecodeBufferToMesh( decoderBuffer, dracoGeometry );
|
||||
|
||||
} else if ( geometryType === draco.POINT_CLOUD ) {
|
||||
|
||||
dracoGeometry = new draco.PointCloud();
|
||||
decodingStatus = decoder.DecodeBufferToPointCloud( decoderBuffer, dracoGeometry );
|
||||
|
||||
} else {
|
||||
|
||||
throw new Error( 'THREE.DRACOLoader: Unexpected geometry type.' );
|
||||
|
||||
}
|
||||
|
||||
if ( ! decodingStatus.ok() || dracoGeometry.ptr === 0 ) {
|
||||
|
||||
throw new Error( 'THREE.DRACOLoader: Decoding failed: ' + decodingStatus.error_msg() );
|
||||
|
||||
}
|
||||
|
||||
var geometry = { index: null, attributes: [] };
|
||||
|
||||
// Gather all vertex attributes.
|
||||
for ( var attributeName in attributeIDs ) {
|
||||
|
||||
var attributeType = self[ attributeTypes[ attributeName ] ];
|
||||
|
||||
var attribute;
|
||||
var attributeID;
|
||||
|
||||
// A Draco file may be created with default vertex attributes, whose attribute IDs
|
||||
// are mapped 1:1 from their semantic name (POSITION, NORMAL, ...). Alternatively,
|
||||
// a Draco file may contain a custom set of attributes, identified by known unique
|
||||
// IDs. glTF files always do the latter, and `.drc` files typically do the former.
|
||||
if ( taskConfig.useUniqueIDs ) {
|
||||
|
||||
attributeID = attributeIDs[ attributeName ];
|
||||
attribute = decoder.GetAttributeByUniqueId( dracoGeometry, attributeID );
|
||||
|
||||
} else {
|
||||
|
||||
attributeID = decoder.GetAttributeId( dracoGeometry, draco[ attributeIDs[ attributeName ] ] );
|
||||
|
||||
if ( attributeID === - 1 ) continue;
|
||||
|
||||
attribute = decoder.GetAttribute( dracoGeometry, attributeID );
|
||||
|
||||
}
|
||||
|
||||
geometry.attributes.push( decodeAttribute( draco, decoder, dracoGeometry, attributeName, attributeType, attribute ) );
|
||||
|
||||
}
|
||||
|
||||
// Add index.
|
||||
if ( geometryType === draco.TRIANGULAR_MESH ) {
|
||||
|
||||
geometry.index = decodeIndex( draco, decoder, dracoGeometry );
|
||||
|
||||
}
|
||||
|
||||
draco.destroy( dracoGeometry );
|
||||
|
||||
return geometry;
|
||||
|
||||
}
|
||||
|
||||
function decodeIndex( draco, decoder, dracoGeometry ) {
|
||||
|
||||
var numFaces = dracoGeometry.num_faces();
|
||||
var numIndices = numFaces * 3;
|
||||
var byteLength = numIndices * 4;
|
||||
|
||||
var ptr = draco._malloc( byteLength );
|
||||
decoder.GetTrianglesUInt32Array( dracoGeometry, byteLength, ptr );
|
||||
var index = new Uint32Array( draco.HEAPF32.buffer, ptr, numIndices ).slice();
|
||||
draco._free( ptr );
|
||||
|
||||
return { array: index, itemSize: 1 };
|
||||
|
||||
}
|
||||
|
||||
function decodeAttribute( draco, decoder, dracoGeometry, attributeName, attributeType, attribute ) {
|
||||
|
||||
var numComponents = attribute.num_components();
|
||||
var numPoints = dracoGeometry.num_points();
|
||||
var numValues = numPoints * numComponents;
|
||||
var byteLength = numValues * attributeType.BYTES_PER_ELEMENT;
|
||||
var dataType = getDracoDataType( draco, attributeType );
|
||||
|
||||
var ptr = draco._malloc( byteLength );
|
||||
decoder.GetAttributeDataArrayForAllPoints( dracoGeometry, attribute, dataType, byteLength, ptr );
|
||||
var array = new attributeType( draco.HEAPF32.buffer, ptr, numValues ).slice();
|
||||
draco._free( ptr );
|
||||
|
||||
return {
|
||||
name: attributeName,
|
||||
array: array,
|
||||
itemSize: numComponents
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
function getDracoDataType( draco, attributeType ) {
|
||||
|
||||
switch ( attributeType ) {
|
||||
|
||||
case Float32Array: return draco.DT_FLOAT32;
|
||||
case Int8Array: return draco.DT_INT8;
|
||||
case Int16Array: return draco.DT_INT16;
|
||||
case Int32Array: return draco.DT_INT32;
|
||||
case Uint8Array: return draco.DT_UINT8;
|
||||
case Uint16Array: return draco.DT_UINT16;
|
||||
case Uint32Array: return draco.DT_UINT32;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
DRACOLoader.taskCache = new WeakMap();
|
||||
|
||||
/** Deprecated static methods */
|
||||
|
||||
/** @deprecated */
|
||||
DRACOLoader.setDecoderPath = function () {
|
||||
|
||||
console.warn( 'THREE.DRACOLoader: The .setDecoderPath() method has been removed. Use instance methods.' );
|
||||
|
||||
};
|
||||
|
||||
/** @deprecated */
|
||||
DRACOLoader.setDecoderConfig = function () {
|
||||
|
||||
console.warn( 'THREE.DRACOLoader: The .setDecoderConfig() method has been removed. Use instance methods.' );
|
||||
|
||||
};
|
||||
|
||||
/** @deprecated */
|
||||
DRACOLoader.releaseDecoderModule = function () {
|
||||
|
||||
console.warn( 'THREE.DRACOLoader: The .releaseDecoderModule() method has been removed. Use instance methods.' );
|
||||
|
||||
};
|
||||
|
||||
/** @deprecated */
|
||||
DRACOLoader.getDecoderModule = function () {
|
||||
|
||||
console.warn( 'THREE.DRACOLoader: The .getDecoderModule() method has been removed. Use instance methods.' );
|
||||
|
||||
};
|
||||
|
||||
export { DRACOLoader };
|
||||
2418
libs/three.js/loaders/EXRLoader.js
Normal file
2418
libs/three.js/loaders/EXRLoader.js
Normal file
File diff suppressed because it is too large
Load Diff
4205
libs/three.js/loaders/FBXLoader.js
Normal file
4205
libs/three.js/loaders/FBXLoader.js
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user