-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #412 from K3D-tools/devel
2.15.3
- Loading branch information
Showing
23 changed files
with
259 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1 @@ | ||
<nav class="bd-links" id="bd-docs-nav" aria-label="{{ _('Main navigation') }}"> | ||
<div class="bd-toc-item active"> | ||
{{ generate_nav_html("raw", | ||
show_nav_level=0|int, | ||
maxdepth=2|int, | ||
collapse=False|tobool, | ||
includehidden=True|tobool) }} | ||
</div> | ||
<script> | ||
$(".bd-toc-item").children("ul").addClass("nav bd-sidenav"); | ||
</script> | ||
</nav> | ||
<img src="_static/logo.png" alt="K3D-Jupyter logo"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
K3D-jupyter Documentation | ||
=========================== | ||
Overview | ||
======== | ||
|
||
.. raw:: html | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Interactions handlers for standard object | ||
* @memberof K3D.Providers.ThreeJS.Interactions | ||
*/ | ||
|
||
function prepareParam(param) { | ||
return { | ||
position: param.point.toArray(), | ||
distance: param.distance, | ||
index: param.index, | ||
K3DIdentifier: param.object.K3DIdentifier, | ||
}; | ||
} | ||
|
||
module.exports = function (object, K3D) { | ||
return { | ||
onHover(intersect) { | ||
K3D.dispatch(K3D.events.OBJECT_HOVERED, prepareParam(intersect)); | ||
return false; | ||
}, | ||
onClick(intersect) { | ||
K3D.dispatch(K3D.events.OBJECT_CLICKED, prepareParam(intersect)); | ||
return false; | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
const threeMeshBVH = require('three-mesh-bvh'); | ||
const THREE = require('three'); | ||
|
||
module.exports = { | ||
prepareGeometry(geometry) { | ||
const bvhGeometry = geometry.clone(); | ||
const indices = []; | ||
|
||
let verticesLength = bvhGeometry.attributes.position.count; | ||
for (let i = 0, l = verticesLength; i < l; i++) { | ||
indices.push(i, i, i); | ||
} | ||
bvhGeometry.setIndex(indices); | ||
|
||
return bvhGeometry; | ||
}, | ||
|
||
Intersect(object) { | ||
return function (raycaster) { | ||
let intersects = []; | ||
|
||
const inverseMatrix = new THREE.Matrix4(); | ||
inverseMatrix.copy(object.matrixWorld).invert(); | ||
raycaster.ray.applyMatrix4(inverseMatrix); | ||
|
||
const { ray } = raycaster; | ||
let closestDistance = Infinity; | ||
|
||
let threshold = object.material.size / 2.0 || 1; | ||
let localThreshold = threshold / ((object.scale.x + object.scale.y + object.scale.z) / 3); | ||
let localThresholdSq = localThreshold * localThreshold; | ||
|
||
let ret = null; | ||
|
||
object.geometry.boundsTree.shapecast({ | ||
boundsTraverseOrder: function (box) { | ||
return box.distanceToPoint(ray.origin); | ||
}, | ||
intersectsBounds: function (box, isLeaf, score) { | ||
if (score > closestDistance) { | ||
return threeMeshBVH.NOT_INTERSECTED; | ||
} | ||
|
||
box.expandByScalar(localThreshold); | ||
return ray.intersectsBox(box) ? threeMeshBVH.INTERSECTED : threeMeshBVH.NOT_INTERSECTED; | ||
|
||
}, | ||
intersectsTriangle: function (triangle, triangleIndex) { | ||
const distancesToRaySq = ray.distanceSqToPoint(triangle.a); | ||
|
||
if (object.geometry.attributes.sizes || object.isInstancedMesh) { | ||
|
||
if (object.geometry.attributes.sizes) { | ||
threshold = object.geometry.attributes.sizes.array[triangleIndex] / 2.0; | ||
} | ||
|
||
if (object.isInstancedMesh) { | ||
let matrix = new THREE.Matrix4().fromArray(object.instanceMatrix.array, triangleIndex * 16); | ||
threshold = matrix.getMaxScaleOnAxis() / 2.0; | ||
} | ||
|
||
localThreshold = threshold / ((object.scale.x + object.scale.y + object.scale.z) / 3); | ||
localThresholdSq = localThreshold * localThreshold; | ||
} | ||
|
||
if (distancesToRaySq < localThresholdSq) { | ||
const distanceToPoint = ray.origin.distanceTo(triangle.a); | ||
|
||
if (distanceToPoint < closestDistance) { | ||
closestDistance = distanceToPoint; | ||
|
||
ret = { | ||
object: object, | ||
point: triangle.a, | ||
distance: distanceToPoint, | ||
index: triangleIndex | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
|
||
if (closestDistance !== Infinity) { | ||
intersects.push(ret); | ||
} | ||
|
||
return intersects; | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.