Skip to content

Commit

Permalink
threejs bump to 0.138.2
Browse files Browse the repository at this point in the history
Grid bounds and scaling #335
bump to 2.13.0
  • Loading branch information
artur-trzesiok committed Apr 6, 2022
1 parent 81215ae commit 7eb26f5
Show file tree
Hide file tree
Showing 101 changed files with 39 additions and 30 deletions.
6 changes: 4 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
git add and git commit
rm -rf build
rm -rf dist
python setup.py sdist upload
python setup.py bdist_wheel upload
pip install -ve .
python setup.py sdist
python setup.py bdist_wheel
twine upload dist/*
cd js
grunt build
npm publish
Expand Down
4 changes: 2 additions & 2 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "k3d",
"version": "2.12.0",
"version": "2.13.0",
"description": "3D visualization library",
"author": "k3d team",
"main": "src/index.js",
Expand Down Expand Up @@ -68,7 +68,7 @@
"screenfull": "^5.1.0",
"stats.js": "^0.17.0",
"style-loader": "^2.0.0",
"three": "^0.137.4",
"three": "^0.138.2",
"three-mesh-bvh": "^0.3.7"
}
}
3 changes: 3 additions & 0 deletions js/src/providers/threejs/initializers/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ module.exports = function (K3D) {
antialias: K3D.parameters.antialias > 0,
preserveDrawingBuffer: true,
alpha: true,
stencil: true,
powerPreference: 'high-performance',
});

self.renderer = new THREE.WebGLRenderer({
alpha: true,
precision: "highp",
premultipliedAlpha: true,
antialias: K3D.parameters.antialias > 0,
logarithmicDepthBuffer: K3D.parameters.logarithmicDepthBuffer,
canvas,
Expand Down Expand Up @@ -75,6 +77,7 @@ module.exports = function (K3D) {
console.log('K3D: (UNMASKED_VENDOR_WEBGL)', gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL));
console.log('K3D: (UNMASKED_RENDERER_WEBGL)', gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL));
console.log('K3D: (depth bits)', gl.getParameter(gl.DEPTH_BITS));
console.log('K3D: (stencil bits)', gl.getParameter(gl.STENCIL_BITS));

function standardRender(scene, camera, rt) {
if (typeof (rt) === 'undefined') {
Expand Down
46 changes: 25 additions & 21 deletions js/src/providers/threejs/initializers/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,11 @@ function generateAxesHelper(K3D, axesHelper) {
return promises;
}

function ensureTwoTicksOnGrids(sceneBoundingBox, majorScale) {
const size = sceneBoundingBox.getSize(new THREE.Vector3());

['x', 'y', 'z'].forEach((axis) => {
const dist = size[axis] / majorScale;

if (dist <= 2.0) {
sceneBoundingBox.min[axis] -= (1.0 - dist / 2.0 + 0.0001) * majorScale;
sceneBoundingBox.max[axis] += (1.0 - dist / 2.0 + 0.0001) * majorScale;
}
});
}

function getSceneBoundingBox() {
/* jshint validthis:true */

const sceneBoundingBox = new THREE.Box3();
let objectBoundingBox;

this.K3DObjects.traverse((object) => {
let isK3DObject = false;
let ref = object;
Expand All @@ -92,6 +78,7 @@ function getSceneBoundingBox() {

if (isK3DObject
&& typeof (object.position.z) !== 'undefined'
&& object.visible
&& (object.geometry || object.boundingBox)) {
if (object.geometry && object.geometry.boundingBox) {
objectBoundingBox = object.geometry.boundingBox.clone();
Expand Down Expand Up @@ -239,7 +226,7 @@ function rebuildSceneData(K3D, grids, axesHelper, force) {
axesHelper.width = 100;
axesHelper.height = 100;
}

if (updateAxesHelper) {
if (K3D.parameters.axesHelper > 0) {
generateAxesHelper(K3D, axesHelper).forEach((p) => {
Expand All @@ -261,7 +248,13 @@ function rebuildSceneData(K3D, grids, axesHelper, force) {
majorScale = pow10ceil(Math.max(size.x, size.y, size.z)) / 10.0;
minorScale = majorScale / 10.0;

ensureTwoTicksOnGrids(sceneBoundingBox, majorScale);
['x', 'y', 'z'].forEach(function (axis) {
if (sceneBoundingBox.min[axis] === sceneBoundingBox.max[axis]) {
sceneBoundingBox.min[axis] -= majorScale / 2.0;
sceneBoundingBox.max[axis] += majorScale / 2.0;
}
});
size = sceneBoundingBox.getSize(new THREE.Vector3());

sceneBoundingBox.min = new THREE.Vector3(
Math.floor(sceneBoundingBox.min.x / majorScale) * majorScale,
Expand Down Expand Up @@ -329,16 +322,28 @@ function rebuildSceneData(K3D, grids, axesHelper, force) {
// create labels
Object.keys(grids.labelsOnEdges).forEach((key) => {
const iterateAxis = _.difference(['x', 'y', 'z'], key.replace(/[^xyz]/g, '').split(''))[0];
const iterationCount = size[iterateAxis] / majorScale;
const deltaValue = unitVectors[iterateAxis].clone().multiplyScalar(majorScale);
const deltaPosition = unitVectors[iterateAxis].clone().multiplyScalar(
let iterationCount = size[iterateAxis] / majorScale;

let deltaValue = unitVectors[iterateAxis].clone().multiplyScalar(majorScale);
let deltaPosition = unitVectors[iterateAxis].clone().multiplyScalar(
grids.labelsOnEdges[key].p[0].distanceTo(grids.labelsOnEdges[key].p[1]) / iterationCount,
);
let j;
let v;
let p;
let label;

if (iterationCount <= 2) {
let originalIterationCount = iterationCount;

iterationCount = originalIterationCount * 5;
deltaValue = unitVectors[iterateAxis].clone()
.multiplyScalar(originalIterationCount * majorScale / iterationCount);
deltaPosition = unitVectors[iterateAxis].clone().multiplyScalar(
grids.labelsOnEdges[key].p[0].distanceTo(grids.labelsOnEdges[key].p[1]) / iterationCount,
);
}

for (j = 1; j <= iterationCount - 1; j++) {
v = grids.labelsOnEdges[key].v[0].clone().add(deltaValue.clone().multiplyScalar(j));
p = grids.labelsOnEdges[key].p[0].clone().add(deltaPosition.clone().multiplyScalar(j));
Expand Down Expand Up @@ -408,8 +413,7 @@ function rebuildSceneData(K3D, grids, axesHelper, force) {
const delta = unitVectors[iterateAxis].clone().multiplyScalar(minorScale);
let p1;
let p2;
let
j;
let j;

for (j = 0; j <= size[iterateAxis] / minorScale; j++) {
p1 = plane.p1.clone().add(delta.clone().multiplyScalar(j));
Expand Down
2 changes: 1 addition & 1 deletion js/src/providers/threejs/objects/MIP.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {
modelMatrix.set.apply(modelMatrix, config.model_matrix.data);
modelMatrix.decompose(translation, rotation, scale);

const texture = new THREE.DataTexture3D(
const texture = new THREE.Data3DTexture(
config.volume.data,
config.volume.shape[2],
config.volume.shape[1],
Expand Down
2 changes: 1 addition & 1 deletion js/src/providers/threejs/objects/MeshVolume.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
geometry.setIndex(new THREE.BufferAttribute(indices, 1));

const texture = new THREE.DataTexture3D(
const texture = new THREE.Data3DTexture(
config.volume.data,
config.volume.shape[2],
config.volume.shape[1],
Expand Down
2 changes: 1 addition & 1 deletion js/src/providers/threejs/objects/Volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = {
modelMatrix.set.apply(modelMatrix, config.model_matrix.data);
modelMatrix.decompose(translation, rotation, scale);

const texture = new THREE.DataTexture3D(
const texture = new THREE.Data3DTexture(
config.volume.data,
config.volume.shape[2],
config.volume.shape[1],
Expand Down
Binary file modified k3d/test/references/line_advanced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/line_mesh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/line_mesh_clipping_plane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/line_simple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/line_simple_clipping_plane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/line_simple_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/line_simplified_mesh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/line_thick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/line_thick_clipping_plane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed k3d/test/references/linux/labels.png
Binary file not shown.
Binary file removed k3d/test/references/linux/labels_without_box.png
Binary file not shown.
Binary file removed k3d/test/references/linux/text.png
Binary file not shown.
Binary file removed k3d/test/references/linux/text2d.png
Binary file not shown.
Binary file removed k3d/test/references/linux/text2d_without_box.png
Binary file not shown.
Binary file removed k3d/test/references/linux/text_without_box.png
Binary file not shown.
Binary file removed k3d/test/references/linux/texture_text.png
Binary file not shown.
Binary file removed k3d/test/references/linux/vectors_labels.png
Binary file not shown.
Binary file not shown.
Binary file modified k3d/test/references/marching_cubes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/marching_cubes_dynamic_level.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/marching_cubes_non_uniformly_spaced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/marching_cubes_smoothed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/marching_cubes_wireframe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/mesh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/mesh_advanced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified k3d/test/references/mesh_advanced_opacity.png
Binary file modified k3d/test/references/mesh_advanced_smoothed.png
Binary file modified k3d/test/references/mesh_advanced_wireframe.png
Binary file modified k3d/test/references/mesh_attribute.png
Binary file modified k3d/test/references/mesh_attribute_advanced.png
Binary file modified k3d/test/references/mesh_attribute_advanced_clipping_planes.png
Binary file modified k3d/test/references/mesh_triangle_attribute.png
Binary file modified k3d/test/references/mesh_volume_data.png
Binary file modified k3d/test/references/mip.png
Binary file modified k3d/test/references/mip_opacity_function.png
Binary file modified k3d/test/references/points_3d.png
Binary file modified k3d/test/references/points_3dSpecular.png
Binary file modified k3d/test/references/points_3dSpecular_sizes.png
Binary file modified k3d/test/references/points_3d_clipping_plane.png
Binary file modified k3d/test/references/points_3d_no_opacity.png
Binary file modified k3d/test/references/points_3d_no_opacity_with_plane.png
Binary file modified k3d/test/references/points_dot.png
Binary file modified k3d/test/references/points_flat.png
Binary file modified k3d/test/references/points_mesh.png
Binary file modified k3d/test/references/points_mesh_clipping_plane.png
Binary file modified k3d/test/references/points_mesh_high_detail.png
Binary file modified k3d/test/references/points_mesh_low_detail.png
Binary file modified k3d/test/references/points_mesh_sizes.png
Binary file modified k3d/test/references/stl.png
Binary file modified k3d/test/references/stl_color.png
Binary file modified k3d/test/references/stl_smooth.png
Binary file modified k3d/test/references/stl_wireframe.png
Binary file modified k3d/test/references/surface.png
Binary file modified k3d/test/references/surface_attribute.png
Binary file modified k3d/test/references/surface_attribute_low.png
Binary file modified k3d/test/references/surface_attribute_low_dynamic_smooth.png
Binary file modified k3d/test/references/surface_attribute_low_dynamic_wireframe.png
Binary file modified k3d/test/references/surface_dynamic_color.png
Binary file modified k3d/test/references/texture.png
Binary file modified k3d/test/references/texture_attribute.png
Binary file modified k3d/test/references/texture_attribute_dynamic_interpolation.png
Binary file modified k3d/test/references/texture_dynamic_change.png
Binary file modified k3d/test/references/vector_field.png
Binary file modified k3d/test/references/vector_field_3d.png
Binary file modified k3d/test/references/vector_field_3d_no_head.png
Binary file modified k3d/test/references/vector_field_3d_scale.png
Binary file modified k3d/test/references/vector_field_no_head.png
Binary file modified k3d/test/references/vector_field_scale.png
Binary file modified k3d/test/references/vectors.png
Binary file modified k3d/test/references/vectors_advance.png
Binary file modified k3d/test/references/volume.png
Binary file modified k3d/test/references/volume_alpha_coef.png
Binary file modified k3d/test/references/volume_opacity_function.png
Binary file modified k3d/test/references/voxels.png
Binary file modified k3d/test/references/voxels_box.png
Binary file modified k3d/test/references/voxels_group.png
Binary file modified k3d/test/references/voxels_group_opacity.png
Binary file modified k3d/test/references/voxels_group_wireframe.png
Binary file modified k3d/test/references/voxels_outline.png
Binary file modified k3d/test/references/voxels_outline_clipping_plane.png
Binary file modified k3d/test/references/voxels_outline_dynamic_outlines_color.png
Binary file modified k3d/test/references/voxels_outline_opacity.png
Binary file modified k3d/test/references/voxels_sparse.png
Binary file modified k3d/test/references/voxels_wireframe.png
Binary file modified k3d/test/references/win32/labels.png
Binary file modified k3d/test/references/win32/labels_without_box.png
Binary file modified k3d/test/references/win32/text.png
Binary file modified k3d/test/references/win32/text2d.png
Binary file modified k3d/test/references/win32/text2d_without_box.png
Binary file modified k3d/test/references/win32/text_without_box.png
Binary file modified k3d/test/references/win32/texture_text.png
Binary file modified k3d/test/references/win32/vectors_labels.png
Binary file modified k3d/test/references/win32/vectors_labels_dynamic_head_size.png
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "k3d",
"version": "2.12.0",
"version": "2.13.0",
"description": "3D visualization library",
"keywords": [
"jupyter",
Expand Down Expand Up @@ -52,7 +52,7 @@
"screenfull": "^5.1.0",
"stats.js": "^0.17.0",
"style-loader": "^2.0.0",
"three": "^0.137.4",
"three": "^0.138.2",
"three-mesh-bvh": "^0.3.7"
},
"devDependencies": {
Expand Down

0 comments on commit 7eb26f5

Please sign in to comment.