remove unused background.gif; add textured mesh object & demo; update jstree demos
This commit is contained in:
parent
624e0f06b8
commit
657bd35bbe
4
.gitignore
vendored
4
.gitignore
vendored
@ -8,4 +8,6 @@ docs/.how_does_loading_nodes_work.md.html
|
||||
docs/.materials_and_rendermodes.md.html
|
||||
docs/.how_to_create_your_own_pointcloud_loader.md.html
|
||||
examples/index.html
|
||||
.project
|
||||
.project
|
||||
pointclouds/retz
|
||||
pointclouds/NVIDIA_Ph01-20160403_tiles_converted
|
||||
|
||||
360
examples/sorvilier_feature_test.html
Normal file
360
examples/sorvilier_feature_test.html
Normal file
@ -0,0 +1,360 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||
<title>Potree Viewer</title>
|
||||
|
||||
<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/perfect-scrollbar/css/perfect-scrollbar.css">
|
||||
<link rel="stylesheet" href="../libs/openlayers3/ol.css" type="text/css">
|
||||
<link rel="stylesheet" href="../libs/spectrum/spectrum.css" type="text/css">
|
||||
<link rel="stylesheet" href="../libs/jstree/themes/mixed/style.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<script src="../libs/jquery/jquery-3.1.1.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
|
||||
<script src="../libs/perfect-scrollbar/js/perfect-scrollbar.jquery.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.js"></script>
|
||||
<script src="../libs/other/stats.min.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/other/PLYLoader.js"></script>
|
||||
<script src="../libs/other/OBJLoader.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
<script src="../libs/proj4/proj4.js"></script>
|
||||
<script src="../libs/openlayers3/ol.js"></script>
|
||||
<script src="../libs/i18next/i18next.js"></script>
|
||||
<script src="../libs/jstree/jstree.js"></script>
|
||||
|
||||
<script src="../build/potree/potree.js"></script>
|
||||
<!--<script src="../src/viewer/sidebar.js"></script>-->
|
||||
|
||||
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
|
||||
<!-- INCLUDE SETTINGS HERE -->
|
||||
|
||||
<script src="../libs/plasio/js/laslaz.js"></script>
|
||||
<script src="../libs/plasio/vendor/bluebird.js"></script>
|
||||
|
||||
<div class="potree_container" style="position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; ">
|
||||
<div id="potree_render_area"></div>
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
viewer.setEDLEnabled(true);
|
||||
viewer.setFOV(60);
|
||||
viewer.setPointBudget(1*1000*1000);
|
||||
viewer.loadSettingsFromURL();
|
||||
|
||||
viewer.setDescription("Point cloud courtesy of <a target='_blank' href='https://www.sigeom.ch/'>sigeom sa</a>");
|
||||
|
||||
viewer.loadGUI(() => {
|
||||
viewer.setLanguage('en');
|
||||
$("#menu_tools").next().show();
|
||||
$("#menu_scene").next().show();
|
||||
viewer.toggleSidebar();
|
||||
});
|
||||
|
||||
// Sigeom
|
||||
Potree.loadPointCloud("../pointclouds/vol_total/cloud.js", "sigeom.sa", function(e){
|
||||
let scene = viewer.scene;
|
||||
scene.addPointCloud(e.pointcloud);
|
||||
|
||||
let material = e.pointcloud.material;
|
||||
material.size = 1;
|
||||
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
|
||||
scene.view.position.set(589974.341, 231698.397, 986.146);
|
||||
scene.view.lookAt(new THREE.Vector3(589851.587, 231428.213, 715.634));
|
||||
// viewer.fitToScreen();
|
||||
});
|
||||
|
||||
{ // MEASUREMENTS
|
||||
let scene = viewer.scene;
|
||||
|
||||
{ // DISTANCE MEASURE
|
||||
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(589822.50, 231315.90, 744.45));
|
||||
|
||||
scene.addMeasurement(measure);
|
||||
}
|
||||
|
||||
{ // ANGLE MEASURE
|
||||
let measure = new Potree.Measure();
|
||||
measure.name = "Angle Sample";
|
||||
measure.closed = true;
|
||||
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(589860.61, 231348.01, 740.33));
|
||||
|
||||
scene.addMeasurement(measure);
|
||||
}
|
||||
|
||||
{ // SINGLE POINT MEASURE
|
||||
let measure = new Potree.Measure();
|
||||
measure.name = "Canopy";
|
||||
measure.showDistances = false;
|
||||
measure.showCoordinates = true;
|
||||
measure.maxMarkers = 1;
|
||||
measure.addMarker(new THREE.Vector3(589853.73, 231300.24, 775.48));
|
||||
|
||||
scene.addMeasurement(measure);
|
||||
}
|
||||
|
||||
{ // HEIGHT MEASURE
|
||||
let measure = new Potree.Measure();
|
||||
measure.name = "Tree Height";
|
||||
measure.closed = false;
|
||||
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));
|
||||
|
||||
scene.addMeasurement(measure);
|
||||
}
|
||||
|
||||
{ // AREA MEASURE
|
||||
let measure = new Potree.Measure();
|
||||
measure.name = "Area";
|
||||
measure.closed = true;
|
||||
measure.showArea = true;
|
||||
measure.addMarker(new THREE.Vector3(589899.37, 231300.16, 750.25));
|
||||
measure.addMarker(new THREE.Vector3(589874.60, 231326.06, 743.40));
|
||||
measure.addMarker(new THREE.Vector3(589911.61, 231352.57, 743.58));
|
||||
measure.addMarker(new THREE.Vector3(589943.50, 231300.08, 754.62));
|
||||
|
||||
scene.addMeasurement(measure);
|
||||
}
|
||||
|
||||
{ // PROFILE
|
||||
let profile = new Potree.Profile();
|
||||
profile.setWidth(6)
|
||||
profile.addMarker(new THREE.Vector3(589641.6098756103, 231453.76974998094, 760.4950016784668));
|
||||
profile.addMarker(new THREE.Vector3(589514.4799995422, 231309.46000003815, 775.6249989318848));
|
||||
profile.addMarker(new THREE.Vector3(589512.4600000381, 231504.9597490845, 764.6350010681152));
|
||||
|
||||
scene.addProfile(profile);
|
||||
}
|
||||
}
|
||||
|
||||
{ // ANNOTATIONS
|
||||
let scene = viewer.scene;
|
||||
|
||||
|
||||
scene.annotations.add(new Potree.Annotation({
|
||||
position: [589847.17, 231436.78, 892.60],
|
||||
cameraPosition: [590034.03, 231814.02, 961.68],
|
||||
cameraTarget: [589847.17, 231436.78, 742.60],
|
||||
title: "Sorvilier"
|
||||
}));
|
||||
|
||||
scene.annotations.add(new Potree.Annotation({
|
||||
position: [589850.15, 231300.10, 770.94],
|
||||
title: "Trees",
|
||||
description: `Point cloud of a small section in Sorvilier, Switzerland. <br>
|
||||
Courtesy of sigeom.sa`
|
||||
}));
|
||||
|
||||
scene.annotations.add(new Potree.Annotation({
|
||||
position: [590043.63, 231490.79, 740.78],
|
||||
title: "About Annotations",
|
||||
cameraPosition: [590105.53, 231541.63, 782.05],
|
||||
cameraTarget: [590043.63, 231488.79, 740.78],
|
||||
description: `<ul><li>Click on the annotation label to move a predefined view.</li>
|
||||
<li>Click on the icon to execute the specified action.</li>
|
||||
In this case, the action will bring you to another scene and point cloud.</ul>`,
|
||||
}));
|
||||
|
||||
scene.annotations.add(new Potree.Annotation({
|
||||
position: [589621, 231437, 784],
|
||||
cameraPosition: [589585.81, 231463.63, 804.00],
|
||||
cameraTarget: [589625.86, 231439, 775.38],
|
||||
title: "About Annotations 2",
|
||||
description: `
|
||||
Suitable annotation positions and views can be obtained by
|
||||
looking up the current camera position and target in the "Scene" panel,
|
||||
or by evaluating following lines in your browser's developer console:<br><br>
|
||||
<code>viewer.scene.view.position</code><br>
|
||||
<code>viewer.scene.view.getPivot()</code><br>
|
||||
`
|
||||
}));
|
||||
|
||||
scene.annotations.add(new Potree.Annotation({
|
||||
position: [589980, 231236.83, 783.89],
|
||||
title: "About Annotations 1",
|
||||
description: `
|
||||
Annotations mark and describe locations.
|
||||
They can move users to a predefined location on click,
|
||||
and provide action buttons to offer easily accessible
|
||||
functionality at certain points of interest.
|
||||
`
|
||||
}));
|
||||
|
||||
scene.annotations.add(new Potree.Annotation({
|
||||
position: [589880, 231236.83, 783.89],
|
||||
title: "About Annotations 2",
|
||||
description: `
|
||||
Suitable annotation positions and views can be obtained by
|
||||
looking up the current camera position and target in the "Scene" panel,
|
||||
or by evaluating following lines in your browser's developer console:<br><br>
|
||||
<code>viewer.scene.view.position</code><br>
|
||||
<code>viewer.scene.view.getPivot()</code><br>
|
||||
`
|
||||
}));
|
||||
|
||||
scene.annotations.add(new Potree.Annotation({
|
||||
title: "Actions: ",
|
||||
position: [589769.27, 231236.83, 783.89],
|
||||
description: `This annotation has actions that switch between elevation and color rendering modes.`,
|
||||
actions: [{
|
||||
"icon": Potree.resourcePath + "/icons/profile.svg",
|
||||
"onclick": function(){
|
||||
for(let pointcloud of viewer.scene.pointclouds){
|
||||
pointcloud.material.pointColorType = Potree.PointColorType.ELEVATION;
|
||||
pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
}
|
||||
}
|
||||
},{
|
||||
"icon": Potree.resourcePath + "/icons/rgb.png",
|
||||
"onclick": function(){
|
||||
for(let pointcloud of viewer.scene.pointclouds){
|
||||
pointcloud.material.pointColorType = Potree.PointColorType.RGB;
|
||||
pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
}
|
||||
}
|
||||
}]
|
||||
}));
|
||||
}
|
||||
|
||||
{
|
||||
let manager = new THREE.LoadingManager();
|
||||
manager.onProgress = function ( item, loaded, total ) {
|
||||
console.log( item, loaded, total );
|
||||
};
|
||||
let textureLoader = new THREE.TextureLoader( manager );
|
||||
let texture = textureLoader.load(`${Potree.resourcePath}/textures/brick_pavement.jpg`);
|
||||
let onProgress = function ( xhr ) {
|
||||
if ( xhr.lengthComputable ) {
|
||||
let percentComplete = xhr.loaded / xhr.total * 100;
|
||||
console.log( Math.round(percentComplete, 2) + '% downloaded' );
|
||||
}
|
||||
};
|
||||
texture.wrapS = THREE.RepeatWrapping;
|
||||
texture.wrapT = THREE.RepeatWrapping;
|
||||
|
||||
let onError = function ( xhr ) {};
|
||||
let loader = new THREE.OBJLoader( manager );
|
||||
loader.load(`${Potree.resourcePath}/models/stanford_bunny_reduced.obj`, function ( object ) {
|
||||
object.traverse( function ( child ) {
|
||||
if ( child instanceof THREE.Mesh ) {
|
||||
child.material.map = texture;
|
||||
}
|
||||
} );
|
||||
|
||||
object.position.set(589871.587, 231528.213, 725.634);
|
||||
object.scale.multiplyScalar(500);
|
||||
object.rotation.set(Math.PI / 2, Math.PI, 0)
|
||||
|
||||
viewer.scene.scene.add( object );
|
||||
|
||||
viewer.onGUILoaded(() => {
|
||||
// Add entries to object list in sidebar
|
||||
let tree = $(`#jstree_scene`);
|
||||
let parentNode = "other";
|
||||
|
||||
let bunnyID = tree.jstree('create_node', parentNode, {
|
||||
text: "Bunny Textured",
|
||||
icon: `${Potree.resourcePath}/icons/triangle.svg`,
|
||||
data: object
|
||||
},
|
||||
"last", false, false);
|
||||
tree.jstree(object.visible ? "check_node" : "uncheck_node", bunnyID);
|
||||
|
||||
tree.jstree("open_node", parentNode);
|
||||
});
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
|
||||
}
|
||||
|
||||
var loader = new THREE.PLYLoader();
|
||||
loader.load( Potree.resourcePath + "/models/stanford_bunny_reduced.ply", (geometry) => {
|
||||
geometry.computeVertexNormals();
|
||||
|
||||
// place three instances of this bunny into the scene
|
||||
|
||||
let mesh1;
|
||||
{
|
||||
let material = new THREE.MeshNormalMaterial();
|
||||
mesh1 = new THREE.Mesh( geometry, material );
|
||||
mesh1.position.set(589961.587, 231428.213, 710.634);
|
||||
mesh1.scale.multiplyScalar(500);
|
||||
mesh1.rotation.set(Math.PI / 2, Math.PI, 0)
|
||||
viewer.scene.scene.add(mesh1);
|
||||
}
|
||||
|
||||
let mesh2;
|
||||
{
|
||||
let material = new THREE.MeshPhysicalMaterial( {
|
||||
color: 0x226666,
|
||||
metalness: 0,
|
||||
roughness: 0.5,
|
||||
clearCoat: 1.0,
|
||||
clearCoatRoughness: 1.0,
|
||||
reflectivity: 1.0
|
||||
} );
|
||||
mesh2 = new THREE.Mesh( geometry, material );
|
||||
mesh2.position.set(589751.587, 231428.213, 725.634);
|
||||
mesh2.scale.multiplyScalar(500);
|
||||
mesh2.rotation.set(Math.PI / 2, Math.PI, 0)
|
||||
viewer.scene.scene.add(mesh2);
|
||||
}
|
||||
|
||||
viewer.onGUILoaded(() => {
|
||||
// Add entries to object list in sidebar
|
||||
let tree = $(`#jstree_scene`);
|
||||
let parentNode = "other";
|
||||
|
||||
let bunny1ID = tree.jstree('create_node', parentNode, {
|
||||
text: "Bunny 1",
|
||||
icon: `${Potree.resourcePath}/icons/triangle.svg`,
|
||||
data: mesh1
|
||||
},
|
||||
"last", false, false);
|
||||
tree.jstree(mesh1.visible ? "check_node" : "uncheck_node", bunny1ID);
|
||||
|
||||
let bunny2ID = tree.jstree('create_node', parentNode, {
|
||||
text: "Bunny 2",
|
||||
icon: `${Potree.resourcePath}/icons/triangle.svg`,
|
||||
data: mesh2
|
||||
},
|
||||
"last", false, false);
|
||||
tree.jstree(mesh2.visible ? "check_node" : "uncheck_node", bunny2ID);
|
||||
|
||||
tree.jstree("open_node", parentNode);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
715
libs/other/OBJLoader.js
Normal file
715
libs/other/OBJLoader.js
Normal file
@ -0,0 +1,715 @@
|
||||
/**
|
||||
* @author mrdoob / http://mrdoob.com/
|
||||
*/
|
||||
|
||||
THREE.OBJLoader = ( function () {
|
||||
|
||||
// o object_name | g group_name
|
||||
var object_pattern = /^[og]\s*(.+)?/;
|
||||
// mtllib file_reference
|
||||
var material_library_pattern = /^mtllib /;
|
||||
// usemtl material_name
|
||||
var material_use_pattern = /^usemtl /;
|
||||
|
||||
function ParserState() {
|
||||
|
||||
var state = {
|
||||
objects: [],
|
||||
object: {},
|
||||
|
||||
vertices: [],
|
||||
normals: [],
|
||||
colors: [],
|
||||
uvs: [],
|
||||
|
||||
materialLibraries: [],
|
||||
|
||||
startObject: function ( name, fromDeclaration ) {
|
||||
|
||||
// If the current object (initial from reset) is not from a g/o declaration in the parsed
|
||||
// file. We need to use it for the first parsed g/o to keep things in sync.
|
||||
if ( this.object && this.object.fromDeclaration === false ) {
|
||||
|
||||
this.object.name = name;
|
||||
this.object.fromDeclaration = ( fromDeclaration !== false );
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
var previousMaterial = ( this.object && typeof this.object.currentMaterial === 'function' ? this.object.currentMaterial() : undefined );
|
||||
|
||||
if ( this.object && typeof this.object._finalize === 'function' ) {
|
||||
|
||||
this.object._finalize( true );
|
||||
|
||||
}
|
||||
|
||||
this.object = {
|
||||
name: name || '',
|
||||
fromDeclaration: ( fromDeclaration !== false ),
|
||||
|
||||
geometry: {
|
||||
vertices: [],
|
||||
normals: [],
|
||||
colors: [],
|
||||
uvs: []
|
||||
},
|
||||
materials: [],
|
||||
smooth: true,
|
||||
|
||||
startMaterial: function ( name, libraries ) {
|
||||
|
||||
var previous = this._finalize( false );
|
||||
|
||||
// New usemtl declaration overwrites an inherited material, except if faces were declared
|
||||
// after the material, then it must be preserved for proper MultiMaterial continuation.
|
||||
if ( previous && ( previous.inherited || previous.groupCount <= 0 ) ) {
|
||||
|
||||
this.materials.splice( previous.index, 1 );
|
||||
|
||||
}
|
||||
|
||||
var material = {
|
||||
index: this.materials.length,
|
||||
name: name || '',
|
||||
mtllib: ( Array.isArray( libraries ) && libraries.length > 0 ? libraries[ libraries.length - 1 ] : '' ),
|
||||
smooth: ( previous !== undefined ? previous.smooth : this.smooth ),
|
||||
groupStart: ( previous !== undefined ? previous.groupEnd : 0 ),
|
||||
groupEnd: - 1,
|
||||
groupCount: - 1,
|
||||
inherited: false,
|
||||
|
||||
clone: function ( index ) {
|
||||
|
||||
var cloned = {
|
||||
index: ( typeof index === 'number' ? index : this.index ),
|
||||
name: this.name,
|
||||
mtllib: this.mtllib,
|
||||
smooth: this.smooth,
|
||||
groupStart: 0,
|
||||
groupEnd: - 1,
|
||||
groupCount: - 1,
|
||||
inherited: false
|
||||
};
|
||||
cloned.clone = this.clone.bind( cloned );
|
||||
return cloned;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
this.materials.push( material );
|
||||
|
||||
return material;
|
||||
|
||||
},
|
||||
|
||||
currentMaterial: function () {
|
||||
|
||||
if ( this.materials.length > 0 ) {
|
||||
|
||||
return this.materials[ this.materials.length - 1 ];
|
||||
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
},
|
||||
|
||||
_finalize: function ( end ) {
|
||||
|
||||
var lastMultiMaterial = this.currentMaterial();
|
||||
if ( lastMultiMaterial && lastMultiMaterial.groupEnd === - 1 ) {
|
||||
|
||||
lastMultiMaterial.groupEnd = this.geometry.vertices.length / 3;
|
||||
lastMultiMaterial.groupCount = lastMultiMaterial.groupEnd - lastMultiMaterial.groupStart;
|
||||
lastMultiMaterial.inherited = false;
|
||||
|
||||
}
|
||||
|
||||
// Ignore objects tail materials if no face declarations followed them before a new o/g started.
|
||||
if ( end && this.materials.length > 1 ) {
|
||||
|
||||
for ( var mi = this.materials.length - 1; mi >= 0; mi -- ) {
|
||||
|
||||
if ( this.materials[ mi ].groupCount <= 0 ) {
|
||||
|
||||
this.materials.splice( mi, 1 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Guarantee at least one empty material, this makes the creation later more straight forward.
|
||||
if ( end && this.materials.length === 0 ) {
|
||||
|
||||
this.materials.push( {
|
||||
name: '',
|
||||
smooth: this.smooth
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
return lastMultiMaterial;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Inherit previous objects material.
|
||||
// Spec tells us that a declared material must be set to all objects until a new material is declared.
|
||||
// If a usemtl declaration is encountered while this new object is being parsed, it will
|
||||
// overwrite the inherited material. Exception being that there was already face declarations
|
||||
// to the inherited material, then it will be preserved for proper MultiMaterial continuation.
|
||||
|
||||
if ( previousMaterial && previousMaterial.name && typeof previousMaterial.clone === 'function' ) {
|
||||
|
||||
var declared = previousMaterial.clone( 0 );
|
||||
declared.inherited = true;
|
||||
this.object.materials.push( declared );
|
||||
|
||||
}
|
||||
|
||||
this.objects.push( this.object );
|
||||
|
||||
},
|
||||
|
||||
finalize: function () {
|
||||
|
||||
if ( this.object && typeof this.object._finalize === 'function' ) {
|
||||
|
||||
this.object._finalize( true );
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
parseVertexIndex: function ( value, len ) {
|
||||
|
||||
var index = parseInt( value, 10 );
|
||||
return ( index >= 0 ? index - 1 : index + len / 3 ) * 3;
|
||||
|
||||
},
|
||||
|
||||
parseNormalIndex: function ( value, len ) {
|
||||
|
||||
var index = parseInt( value, 10 );
|
||||
return ( index >= 0 ? index - 1 : index + len / 3 ) * 3;
|
||||
|
||||
},
|
||||
|
||||
parseUVIndex: function ( value, len ) {
|
||||
|
||||
var index = parseInt( value, 10 );
|
||||
return ( index >= 0 ? index - 1 : index + len / 2 ) * 2;
|
||||
|
||||
},
|
||||
|
||||
addVertex: function ( a, b, c ) {
|
||||
|
||||
var src = this.vertices;
|
||||
var dst = this.object.geometry.vertices;
|
||||
|
||||
dst.push( src[ a + 0 ], src[ a + 1 ], src[ a + 2 ] );
|
||||
dst.push( src[ b + 0 ], src[ b + 1 ], src[ b + 2 ] );
|
||||
dst.push( src[ c + 0 ], src[ c + 1 ], src[ c + 2 ] );
|
||||
|
||||
},
|
||||
|
||||
addVertexLine: function ( a ) {
|
||||
|
||||
var src = this.vertices;
|
||||
var dst = this.object.geometry.vertices;
|
||||
|
||||
dst.push( src[ a + 0 ], src[ a + 1 ], src[ a + 2 ] );
|
||||
|
||||
},
|
||||
|
||||
addNormal: function ( a, b, c ) {
|
||||
|
||||
var src = this.normals;
|
||||
var dst = this.object.geometry.normals;
|
||||
|
||||
dst.push( src[ a + 0 ], src[ a + 1 ], src[ a + 2 ] );
|
||||
dst.push( src[ b + 0 ], src[ b + 1 ], src[ b + 2 ] );
|
||||
dst.push( src[ c + 0 ], src[ c + 1 ], src[ c + 2 ] );
|
||||
|
||||
},
|
||||
|
||||
addColor: function ( a, b, c ) {
|
||||
|
||||
var src = this.colors;
|
||||
var dst = this.object.geometry.colors;
|
||||
|
||||
dst.push( src[ a + 0 ], src[ a + 1 ], src[ a + 2 ] );
|
||||
dst.push( src[ b + 0 ], src[ b + 1 ], src[ b + 2 ] );
|
||||
dst.push( src[ c + 0 ], src[ c + 1 ], src[ c + 2 ] );
|
||||
|
||||
},
|
||||
|
||||
addUV: function ( a, b, c ) {
|
||||
|
||||
var src = this.uvs;
|
||||
var dst = this.object.geometry.uvs;
|
||||
|
||||
dst.push( src[ a + 0 ], src[ a + 1 ] );
|
||||
dst.push( src[ b + 0 ], src[ b + 1 ] );
|
||||
dst.push( src[ c + 0 ], src[ c + 1 ] );
|
||||
|
||||
},
|
||||
|
||||
addUVLine: function ( a ) {
|
||||
|
||||
var src = this.uvs;
|
||||
var dst = this.object.geometry.uvs;
|
||||
|
||||
dst.push( src[ a + 0 ], src[ a + 1 ] );
|
||||
|
||||
},
|
||||
|
||||
addFace: function ( a, b, c, ua, ub, uc, na, nb, nc ) {
|
||||
|
||||
var vLen = this.vertices.length;
|
||||
|
||||
var ia = this.parseVertexIndex( a, vLen );
|
||||
var ib = this.parseVertexIndex( b, vLen );
|
||||
var ic = this.parseVertexIndex( c, vLen );
|
||||
|
||||
this.addVertex( ia, ib, ic );
|
||||
|
||||
if ( ua !== undefined ) {
|
||||
|
||||
var uvLen = this.uvs.length;
|
||||
|
||||
ia = this.parseUVIndex( ua, uvLen );
|
||||
ib = this.parseUVIndex( ub, uvLen );
|
||||
ic = this.parseUVIndex( uc, uvLen );
|
||||
|
||||
this.addUV( ia, ib, ic );
|
||||
|
||||
}
|
||||
|
||||
if ( na !== undefined ) {
|
||||
|
||||
// Normals are many times the same. If so, skip function call and parseInt.
|
||||
var nLen = this.normals.length;
|
||||
ia = this.parseNormalIndex( na, nLen );
|
||||
|
||||
ib = na === nb ? ia : this.parseNormalIndex( nb, nLen );
|
||||
ic = na === nc ? ia : this.parseNormalIndex( nc, nLen );
|
||||
|
||||
this.addNormal( ia, ib, ic );
|
||||
|
||||
}
|
||||
|
||||
if ( this.colors.length > 0 ) {
|
||||
|
||||
this.addColor( ia, ib, ic );
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
addLineGeometry: function ( vertices, uvs ) {
|
||||
|
||||
this.object.geometry.type = 'Line';
|
||||
|
||||
var vLen = this.vertices.length;
|
||||
var uvLen = this.uvs.length;
|
||||
|
||||
for ( var vi = 0, l = vertices.length; vi < l; vi ++ ) {
|
||||
|
||||
this.addVertexLine( this.parseVertexIndex( vertices[ vi ], vLen ) );
|
||||
|
||||
}
|
||||
|
||||
for ( var uvi = 0, l = uvs.length; uvi < l; uvi ++ ) {
|
||||
|
||||
this.addUVLine( this.parseUVIndex( uvs[ uvi ], uvLen ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
state.startObject( '', false );
|
||||
|
||||
return state;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
function OBJLoader( manager ) {
|
||||
|
||||
this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
|
||||
|
||||
this.materials = null;
|
||||
|
||||
}
|
||||
|
||||
OBJLoader.prototype = {
|
||||
|
||||
constructor: OBJLoader,
|
||||
|
||||
load: function ( url, onLoad, onProgress, onError ) {
|
||||
|
||||
var scope = this;
|
||||
|
||||
var loader = new THREE.FileLoader( scope.manager );
|
||||
loader.setPath( this.path );
|
||||
loader.load( url, function ( text ) {
|
||||
|
||||
onLoad( scope.parse( text ) );
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
},
|
||||
|
||||
setPath: function ( value ) {
|
||||
|
||||
this.path = value;
|
||||
|
||||
},
|
||||
|
||||
setMaterials: function ( materials ) {
|
||||
|
||||
this.materials = materials;
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
parse: function ( text ) {
|
||||
|
||||
console.time( 'OBJLoader' );
|
||||
|
||||
var state = new ParserState();
|
||||
|
||||
if ( text.indexOf( '\r\n' ) !== - 1 ) {
|
||||
|
||||
// This is faster than String.split with regex that splits on both
|
||||
text = text.replace( /\r\n/g, '\n' );
|
||||
|
||||
}
|
||||
|
||||
if ( text.indexOf( '\\\n' ) !== - 1 ) {
|
||||
|
||||
// join lines separated by a line continuation character (\)
|
||||
text = text.replace( /\\\n/g, '' );
|
||||
|
||||
}
|
||||
|
||||
var lines = text.split( '\n' );
|
||||
var line = '', lineFirstChar = '';
|
||||
var lineLength = 0;
|
||||
var result = [];
|
||||
|
||||
// Faster to just trim left side of the line. Use if available.
|
||||
var trimLeft = ( typeof ''.trimLeft === 'function' );
|
||||
|
||||
for ( var i = 0, l = lines.length; i < l; i ++ ) {
|
||||
|
||||
line = lines[ i ];
|
||||
|
||||
line = trimLeft ? line.trimLeft() : line.trim();
|
||||
|
||||
lineLength = line.length;
|
||||
|
||||
if ( lineLength === 0 ) continue;
|
||||
|
||||
lineFirstChar = line.charAt( 0 );
|
||||
|
||||
// @todo invoke passed in handler if any
|
||||
if ( lineFirstChar === '#' ) continue;
|
||||
|
||||
if ( lineFirstChar === 'v' ) {
|
||||
|
||||
var data = line.split( /\s+/ );
|
||||
|
||||
switch ( data[ 0 ] ) {
|
||||
|
||||
case 'v':
|
||||
state.vertices.push(
|
||||
parseFloat( data[ 1 ] ),
|
||||
parseFloat( data[ 2 ] ),
|
||||
parseFloat( data[ 3 ] )
|
||||
);
|
||||
if ( data.length === 8 ) {
|
||||
|
||||
state.colors.push(
|
||||
parseFloat( data[ 4 ] ),
|
||||
parseFloat( data[ 5 ] ),
|
||||
parseFloat( data[ 6 ] )
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
break;
|
||||
case 'vn':
|
||||
state.normals.push(
|
||||
parseFloat( data[ 1 ] ),
|
||||
parseFloat( data[ 2 ] ),
|
||||
parseFloat( data[ 3 ] )
|
||||
);
|
||||
break;
|
||||
case 'vt':
|
||||
state.uvs.push(
|
||||
parseFloat( data[ 1 ] ),
|
||||
parseFloat( data[ 2 ] )
|
||||
);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
} else if ( lineFirstChar === 'f' ) {
|
||||
|
||||
var lineData = line.substr( 1 ).trim();
|
||||
var vertexData = lineData.split( /\s+/ );
|
||||
var faceVertices = [];
|
||||
|
||||
// Parse the face vertex data into an easy to work with format
|
||||
|
||||
for ( var j = 0, jl = vertexData.length; j < jl; j ++ ) {
|
||||
|
||||
var vertex = vertexData[ j ];
|
||||
|
||||
if ( vertex.length > 0 ) {
|
||||
|
||||
var vertexParts = vertex.split( '/' );
|
||||
faceVertices.push( vertexParts );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Draw an edge between the first vertex and all subsequent vertices to form an n-gon
|
||||
|
||||
var v1 = faceVertices[ 0 ];
|
||||
|
||||
for ( var j = 1, jl = faceVertices.length - 1; j < jl; j ++ ) {
|
||||
|
||||
var v2 = faceVertices[ j ];
|
||||
var v3 = faceVertices[ j + 1 ];
|
||||
|
||||
state.addFace(
|
||||
v1[ 0 ], v2[ 0 ], v3[ 0 ],
|
||||
v1[ 1 ], v2[ 1 ], v3[ 1 ],
|
||||
v1[ 2 ], v2[ 2 ], v3[ 2 ]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
} else if ( lineFirstChar === 'l' ) {
|
||||
|
||||
var lineParts = line.substring( 1 ).trim().split( " " );
|
||||
var lineVertices = [], lineUVs = [];
|
||||
|
||||
if ( line.indexOf( "/" ) === - 1 ) {
|
||||
|
||||
lineVertices = lineParts;
|
||||
|
||||
} else {
|
||||
|
||||
for ( var li = 0, llen = lineParts.length; li < llen; li ++ ) {
|
||||
|
||||
var parts = lineParts[ li ].split( "/" );
|
||||
|
||||
if ( parts[ 0 ] !== "" ) lineVertices.push( parts[ 0 ] );
|
||||
if ( parts[ 1 ] !== "" ) lineUVs.push( parts[ 1 ] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
state.addLineGeometry( lineVertices, lineUVs );
|
||||
|
||||
} else if ( ( result = object_pattern.exec( line ) ) !== null ) {
|
||||
|
||||
// o object_name
|
||||
// or
|
||||
// g group_name
|
||||
|
||||
// WORKAROUND: https://bugs.chromium.org/p/v8/issues/detail?id=2869
|
||||
// var name = result[ 0 ].substr( 1 ).trim();
|
||||
var name = ( " " + result[ 0 ].substr( 1 ).trim() ).substr( 1 );
|
||||
|
||||
state.startObject( name );
|
||||
|
||||
} else if ( material_use_pattern.test( line ) ) {
|
||||
|
||||
// material
|
||||
|
||||
state.object.startMaterial( line.substring( 7 ).trim(), state.materialLibraries );
|
||||
|
||||
} else if ( material_library_pattern.test( line ) ) {
|
||||
|
||||
// mtl file
|
||||
|
||||
state.materialLibraries.push( line.substring( 7 ).trim() );
|
||||
|
||||
} else if ( lineFirstChar === 's' ) {
|
||||
|
||||
result = line.split( ' ' );
|
||||
|
||||
// smooth shading
|
||||
|
||||
// @todo Handle files that have varying smooth values for a set of faces inside one geometry,
|
||||
// but does not define a usemtl for each face set.
|
||||
// This should be detected and a dummy material created (later MultiMaterial and geometry groups).
|
||||
// This requires some care to not create extra material on each smooth value for "normal" obj files.
|
||||
// where explicit usemtl defines geometry groups.
|
||||
// Example asset: examples/models/obj/cerberus/Cerberus.obj
|
||||
|
||||
/*
|
||||
* http://paulbourke.net/dataformats/obj/
|
||||
* or
|
||||
* http://www.cs.utah.edu/~boulos/cs3505/obj_spec.pdf
|
||||
*
|
||||
* From chapter "Grouping" Syntax explanation "s group_number":
|
||||
* "group_number is the smoothing group number. To turn off smoothing groups, use a value of 0 or off.
|
||||
* Polygonal elements use group numbers to put elements in different smoothing groups. For free-form
|
||||
* surfaces, smoothing groups are either turned on or off; there is no difference between values greater
|
||||
* than 0."
|
||||
*/
|
||||
if ( result.length > 1 ) {
|
||||
|
||||
var value = result[ 1 ].trim().toLowerCase();
|
||||
state.object.smooth = ( value !== '0' && value !== 'off' );
|
||||
|
||||
} else {
|
||||
|
||||
// ZBrush can produce "s" lines #11707
|
||||
state.object.smooth = true;
|
||||
|
||||
}
|
||||
var material = state.object.currentMaterial();
|
||||
if ( material ) material.smooth = state.object.smooth;
|
||||
|
||||
} else {
|
||||
|
||||
// Handle null terminated files without exception
|
||||
if ( line === '\0' ) continue;
|
||||
|
||||
throw new Error( 'THREE.OBJLoader: Unexpected line: "' + line + '"' );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
state.finalize();
|
||||
|
||||
var container = new THREE.Group();
|
||||
container.materialLibraries = [].concat( state.materialLibraries );
|
||||
|
||||
for ( var i = 0, l = state.objects.length; i < l; i ++ ) {
|
||||
|
||||
var object = state.objects[ i ];
|
||||
var geometry = object.geometry;
|
||||
var materials = object.materials;
|
||||
var isLine = ( geometry.type === 'Line' );
|
||||
|
||||
// Skip o/g line declarations that did not follow with any faces
|
||||
if ( geometry.vertices.length === 0 ) continue;
|
||||
|
||||
var buffergeometry = new THREE.BufferGeometry();
|
||||
|
||||
buffergeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( geometry.vertices, 3 ) );
|
||||
|
||||
if ( geometry.normals.length > 0 ) {
|
||||
|
||||
buffergeometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( geometry.normals, 3 ) );
|
||||
|
||||
} else {
|
||||
|
||||
buffergeometry.computeVertexNormals();
|
||||
|
||||
}
|
||||
|
||||
if ( geometry.colors.length > 0 ) {
|
||||
|
||||
buffergeometry.addAttribute( 'color', new THREE.Float32BufferAttribute( geometry.colors, 3 ) );
|
||||
|
||||
}
|
||||
|
||||
if ( geometry.uvs.length > 0 ) {
|
||||
|
||||
buffergeometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( geometry.uvs, 2 ) );
|
||||
|
||||
}
|
||||
|
||||
// Create materials
|
||||
|
||||
var createdMaterials = [];
|
||||
|
||||
for ( var mi = 0, miLen = materials.length; mi < miLen; mi ++ ) {
|
||||
|
||||
var sourceMaterial = materials[ mi ];
|
||||
var material = undefined;
|
||||
|
||||
if ( this.materials !== null ) {
|
||||
|
||||
material = this.materials.create( sourceMaterial.name );
|
||||
|
||||
// mtl etc. loaders probably can't create line materials correctly, copy properties to a line material.
|
||||
if ( isLine && material && ! ( material instanceof THREE.LineBasicMaterial ) ) {
|
||||
|
||||
var materialLine = new THREE.LineBasicMaterial();
|
||||
materialLine.copy( material );
|
||||
material = materialLine;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! material ) {
|
||||
|
||||
material = ( ! isLine ? new THREE.MeshPhongMaterial() : new THREE.LineBasicMaterial() );
|
||||
material.name = sourceMaterial.name;
|
||||
|
||||
}
|
||||
|
||||
material.flatShading = sourceMaterial.smooth ? false : true;
|
||||
|
||||
createdMaterials.push( material );
|
||||
|
||||
}
|
||||
|
||||
// Create mesh
|
||||
|
||||
var mesh;
|
||||
|
||||
if ( createdMaterials.length > 1 ) {
|
||||
|
||||
for ( var mi = 0, miLen = materials.length; mi < miLen; mi ++ ) {
|
||||
|
||||
var sourceMaterial = materials[ mi ];
|
||||
buffergeometry.addGroup( sourceMaterial.groupStart, sourceMaterial.groupCount, mi );
|
||||
|
||||
}
|
||||
|
||||
mesh = ( ! isLine ? new THREE.Mesh( buffergeometry, createdMaterials ) : new THREE.LineSegments( buffergeometry, createdMaterials ) );
|
||||
|
||||
} else {
|
||||
|
||||
mesh = ( ! isLine ? new THREE.Mesh( buffergeometry, createdMaterials[ 0 ] ) : new THREE.LineSegments( buffergeometry, createdMaterials[ 0 ] ) );
|
||||
|
||||
}
|
||||
|
||||
mesh.name = object.name;
|
||||
|
||||
container.add( mesh );
|
||||
|
||||
}
|
||||
|
||||
console.timeEnd( 'OBJLoader' );
|
||||
|
||||
return container;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return OBJLoader;
|
||||
|
||||
} )();
|
||||
111
resources/icons/triangle.svg
Normal file
111
resources/icons/triangle.svg
Normal file
@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="32px"
|
||||
height="32px"
|
||||
id="svg3797"
|
||||
version="1.1"
|
||||
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
|
||||
sodipodi:docname="triangle.svg">
|
||||
<defs
|
||||
id="defs3799" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="22.395604"
|
||||
inkscape:cx="6.2806856"
|
||||
inkscape:cy="9.735117"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
inkscape:grid-bbox="true"
|
||||
inkscape:document-units="px"
|
||||
inkscape:window-width="3840"
|
||||
inkscape:window-height="2066"
|
||||
inkscape:window-x="-11"
|
||||
inkscape:window-y="-11"
|
||||
inkscape:window-maximized="1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid3805" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata3802">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer">
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M -33,23 -19,9"
|
||||
id="path3829"
|
||||
inkscape:connector-curvature="0" />
|
||||
<circle
|
||||
style="fill:#00ff00;fill-opacity:1;stroke:#000000;stroke-width:0.66666669;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path3807-4"
|
||||
cx="-18.499998"
|
||||
cy="8.5"
|
||||
r="3.6666667" />
|
||||
<circle
|
||||
style="fill:#00ff00;fill-opacity:1;stroke:#000000;stroke-width:0.66666669;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path3807"
|
||||
cx="-35.5"
|
||||
cy="25.5"
|
||||
r="3.6666667" />
|
||||
<circle
|
||||
cy="24.062943"
|
||||
cx="6.5721059"
|
||||
id="circle819"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
r="3.5" />
|
||||
<circle
|
||||
r="3.5"
|
||||
style="fill:#ffffff;fill-opacity:0.98449612;stroke:#ffffff;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="circle825"
|
||||
cx="25.358316"
|
||||
cy="24.062943" />
|
||||
<circle
|
||||
cy="8.276"
|
||||
cx="16"
|
||||
id="circle827"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
r="3.5" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 14,11 8,21"
|
||||
id="path829"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path831"
|
||||
d="M 22,24 H 10"
|
||||
style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path835"
|
||||
d="m 18,11 6,10"
|
||||
style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
13
resources/models/stanford_bunny_reduced.mtl
Normal file
13
resources/models/stanford_bunny_reduced.mtl
Normal file
@ -0,0 +1,13 @@
|
||||
# Blender MTL File: 'None'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material.001
|
||||
Ns 96.078431
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 0.640000 0.352654 0.488547
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd C:\\dev\\workspaces\\potree\\develop\\resources\\textures\\brick_pavement.jpg
|
||||
22384
resources/models/stanford_bunny_reduced.obj
Normal file
22384
resources/models/stanford_bunny_reduced.obj
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,23 @@
|
||||
background:
|
||||
http://halfblog.net/2012/09/22/minimalistic-iphone-5-wallpapers/
|
||||
|
||||
|
||||
|
||||
brick_pavement.jpg:
|
||||
http://www.wildtextures.com/terms-of-use/
|
||||
==============================
|
||||
All textures at wildtextures.com are completely free for both, personal and commercial use, however you can’t:
|
||||
|
||||
host textures for download on any other website or server,
|
||||
direct link to texture file from any other website ( however you can link to texture page ),
|
||||
sell them as a stock materials,
|
||||
==============================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 527 KiB |
BIN
resources/textures/brick_pavement.jpg
Normal file
BIN
resources/textures/brick_pavement.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 KiB |
@ -578,7 +578,11 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree {
|
||||
pickMaterial.classification = this.material.classification;
|
||||
if(params.pickClipped){
|
||||
pickMaterial.clipBoxes = this.material.clipBoxes;
|
||||
pickMaterial.clipMode = this.material.clipMode;
|
||||
if(this.material.clipMode === Potree.ClipMode.HIGHLIGHT){
|
||||
pickMaterial.clipMode = Potree.ClipMode.DISABLED;
|
||||
}else{
|
||||
pickMaterial.clipMode = this.material.clipMode;
|
||||
}
|
||||
}else{
|
||||
pickMaterial.clipBoxes = [];
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ initSidebar = (viewer) => {
|
||||
let nodeID = tree.jstree('create_node', parent, {
|
||||
"text": text,
|
||||
"icon": icon,
|
||||
"object": object
|
||||
"data": object
|
||||
},
|
||||
"last", false, false);
|
||||
|
||||
@ -169,30 +169,32 @@ initSidebar = (viewer) => {
|
||||
let pcID = tree.jstree('create_node', "#", { "text": "<b>Point Clouds</b>", "id": "pointclouds"}, "last", false, false);
|
||||
let measurementID = tree.jstree('create_node', "#", { "text": "<b>Measurements</b>", "id": "measurements" }, "last", false, false);
|
||||
let annotationsID = tree.jstree('create_node', "#", { "text": "<b>Annotations</b>", "id": "annotations" }, "last", false, false);
|
||||
let otherID = tree.jstree('create_node', "#", { "text": "<b>Other</b>", "id": "other" }, "last", false, false);
|
||||
|
||||
tree.jstree("check_node", pcID);
|
||||
tree.jstree("check_node", measurementID);
|
||||
tree.jstree("check_node", annotationsID);
|
||||
tree.jstree("check_node", otherID);
|
||||
|
||||
tree.on('ready.jstree', function() {
|
||||
tree.jstree("open_all");
|
||||
});
|
||||
|
||||
tree.on("select_node.jstree", function (e, data) {
|
||||
let object = data.node.original.object;
|
||||
let object = data.node.data;
|
||||
propertiesPanel.set(object);
|
||||
});
|
||||
|
||||
tree.on('dblclick','.jstree-anchor', function (e) {
|
||||
let instance = $.jstree.reference(this);
|
||||
let node = instance.get_node(this);
|
||||
let object = node.original.object;
|
||||
let object = node.data;
|
||||
|
||||
// ignore double click on checkbox
|
||||
if(e.target.classList.contains("jstree-checkbox")){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(object instanceof Potree.PointCloudTree){
|
||||
let box = viewer.getBoundingBox([object]);
|
||||
let node = new THREE.Object3D();
|
||||
@ -232,11 +234,19 @@ initSidebar = (viewer) => {
|
||||
|
||||
viewer.scene.view.position.copy(object.camera.position);
|
||||
viewer.scene.view.lookAt(target);
|
||||
}else if(object instanceof THREE.Object3D){
|
||||
let box = new THREE.Box3().setFromObject(object);
|
||||
|
||||
if(box.getSize().length() > 0){
|
||||
let node = new THREE.Object3D();
|
||||
node.boundingBox = box;
|
||||
viewer.zoomTo(node, 1, 500);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tree.on("uncheck_node.jstree", function(e, data){
|
||||
let object = data.node.original.object;
|
||||
let object = data.node.data;
|
||||
|
||||
if(object){
|
||||
object.visible = false;
|
||||
@ -244,7 +254,7 @@ initSidebar = (viewer) => {
|
||||
});
|
||||
|
||||
tree.on("check_node.jstree", function(e, data){
|
||||
let object = data.node.original.object;
|
||||
let object = data.node.data;
|
||||
|
||||
if(object){
|
||||
object.visible = true;
|
||||
@ -282,6 +292,17 @@ initSidebar = (viewer) => {
|
||||
viewer.scene.addEventListener("volume_added", onVolumeAdded);
|
||||
viewer.scene.addEventListener("polygon_clip_volume_added", onVolumeAdded);
|
||||
|
||||
let onMeasurementRemoved = (e) => {
|
||||
console.log(e);
|
||||
|
||||
let measurementsRoot = $("#jstree_scene").jstree().get_json("measurements");
|
||||
let jsonNode = measurementsRoot.children.find(child => child.data.uuid === e.measurement.uuid);
|
||||
|
||||
tree.jstree("delete_node", jsonNode.id);
|
||||
};
|
||||
|
||||
viewer.scene.addEventListener("measurement_removed", onMeasurementRemoved);
|
||||
|
||||
{
|
||||
let annotationIcon = `${Potree.resourcePath}/icons/target.svg`;
|
||||
this.annotationMapping = new Map();
|
||||
@ -318,12 +339,14 @@ initSidebar = (viewer) => {
|
||||
e.oldScene.removeEventListener("profile_added", onProfileAdded);
|
||||
e.oldScene.removeEventListener("volume_added", onVolumeAdded);
|
||||
e.oldScene.removeEventListener("polygon_clip_volume_added", onVolumeAdded);
|
||||
e.oldScene.removeEventListener("measurement_removed", onMeasurementRemoved);
|
||||
|
||||
e.scene.addEventListener("pointcloud_added", onPointCloudAdded);
|
||||
e.scene.addEventListener("measurement_added", onMeasurementAdded);
|
||||
e.scene.addEventListener("profile_added", onProfileAdded);
|
||||
e.scene.addEventListener("volume_added", onVolumeAdded);
|
||||
e.scene.addEventListener("polygon_clip_volume_added", onVolumeAdded);
|
||||
e.scene.addEventListener("measurement_removed", onMeasurementRemoved);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -407,7 +407,6 @@ Potree.Scene = class extends THREE.EventDispatcher{
|
||||
//this.scene.add(grid);
|
||||
|
||||
{ // background
|
||||
// var texture = THREE.ImageUtils.loadTexture( Potree.resourcePath + '/textures/background.gif' );
|
||||
let texture = Potree.utils.createBackgroundTexture(512, 512);
|
||||
|
||||
texture.minFilter = texture.magFilter = THREE.NearestFilter;
|
||||
@ -468,7 +467,9 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
constructor(domElement, args = {}){
|
||||
super();
|
||||
|
||||
this.renderArea = domElement;
|
||||
this.renderArea = domElement;
|
||||
this.guiLoaded = false;
|
||||
this.guiLoadTasks = [];
|
||||
|
||||
try{
|
||||
|
||||
@ -1286,7 +1287,15 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
}
|
||||
};
|
||||
|
||||
loadGUI (callback) {
|
||||
onGUILoaded(callback){
|
||||
if(this.guiLoaded){
|
||||
callback();
|
||||
}else{
|
||||
this.guiLoadTasks.push(callback);
|
||||
}
|
||||
}
|
||||
|
||||
loadGUI(callback){
|
||||
let viewer = this;
|
||||
let sidebarContainer = $('#potree_sidebar_container');
|
||||
sidebarContainer.load(new URL(Potree.scriptPath + '/sidebar.html').href, () => {
|
||||
@ -1342,6 +1351,12 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
if (callback) {
|
||||
$(callback);
|
||||
}
|
||||
|
||||
this.guiLoaded = true;
|
||||
|
||||
for(let task of this.guiLoadTasks){
|
||||
task();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user