Skip to content

Commit

Permalink
Merge pull request #401 from K3D-tools/devel
Browse files Browse the repository at this point in the history
2.15.1
  • Loading branch information
artur-trzesiok authored Dec 18, 2022
2 parents da6372e + 6f059f6 commit 61d7652
Show file tree
Hide file tree
Showing 25 changed files with 839 additions and 500 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

[![Downloads](https://pepy.tech/badge/k3d)](https://pepy.tech/project/k3d)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/k3d/badges/downloads.svg)](https://anaconda.org/conda-forge/k3d)
[![Build Status](https://travis-ci.org/K3D-tools/K3D-jupyter.svg)](https://travis-ci.org/K3D-tools/K3D-jupyter)
[![Total Alerts](https://img.shields.io/lgtm/alerts/g/K3D-tools/K3D-jupyter.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/K3D-tools/K3D-jupyter/alerts/)
[![Language Grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/K3D-tools/K3D-jupyter.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/K3D-tools/K3D-jupyter/context:javascript)
[![Language Grade: Python](https://img.shields.io/lgtm/grade/python/g/K3D-tools/K3D-jupyter.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/K3D-tools/K3D-jupyter/context:python)
[![CodeQL](https://github.com/K3D-tools/K3D-jupyter/workflows/CodeQL/badge.svg)](https://github.com/K3D-tools/K3D-jupyter/actions)

Jupyter notebook extension for 3D visualization.

Expand Down
46 changes: 44 additions & 2 deletions examples/labels.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,48 @@
"plot.mode = 'callback'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Multipile labels in single object"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"N = 20\n",
"positions = np.random.randn(N,3).astype(np.float32)\n",
"\n",
"plot2 = k3d.plot()\n",
"obj = k3d.label([\"lorem ipsum\"] * N, positions, is_html=True, mode='dynamic')\n",
"# obj = k3d.label([\"lorem ipsum\"] * N, positions, is_html=True, mode='local')\n",
"# obj = k3d.label([\"lorem ipsum\"] * N, positions, is_html=True, mode='side')\n",
"plot2 += obj\n",
"plot2.display()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obj.text= list(map(lambda a: str(a), list(range(N))))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obj.position = np.random.randn(N,3).astype(np.float32)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -138,7 +180,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -152,7 +194,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down
41 changes: 39 additions & 2 deletions examples/text.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,43 @@
"plot.objects[0].label_box = False"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Multipile texts in single object\n",
"\n",
"import numpy as np\n",
"\n",
"N = 20\n",
"positions = np.random.randn(N,3).astype(np.float32)\n",
"\n",
"plot2 = k3d.plot()\n",
"obj = k3d.text([\"lorem ipsum\"] * N, positions, is_html=True)\n",
"plot2 += obj\n",
"plot2.display()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obj.text= list(map(lambda a: str(a), list(range(N))))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obj.position = np.random.randn(N,3).astype(np.float32)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -38,7 +75,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -52,7 +89,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down
41 changes: 39 additions & 2 deletions examples/text2d.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,43 @@
"plot.objects[0].label_box = False"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Multipile texts in single object\n",
"\n",
"import numpy as np\n",
"\n",
"N = 20\n",
"positions = np.random.randn(N,2).astype(np.float32)\n",
"\n",
"plot2 = k3d.plot()\n",
"obj = k3d.text2d([\"lorem ipsum\"] * N, positions, is_html=True)\n",
"plot2 += obj\n",
"plot2.display()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obj.text= list(map(lambda a: str(a), list(range(N))))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obj.position = np.random.randn(N,2).astype(np.float32)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -37,7 +74,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -51,7 +88,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down
39 changes: 37 additions & 2 deletions examples/texture_text.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,41 @@
"plot.display()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Multipile texts in single object\n",
"\n",
"N = 20\n",
"positions = np.random.randn(N,3).astype(np.float32)\n",
"\n",
"plot2 = k3d.plot()\n",
"obj = k3d.texture_text([\"lorem ipsum\"] * N, positions, is_html=True)\n",
"plot2 += obj\n",
"plot2.display()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obj.text = list(map(lambda a: str(a), list(range(N))))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obj.position = np.random.randn(N,3).astype(np.float32)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -28,7 +63,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -42,7 +77,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "k3d",
"version": "2.15.0",
"version": "2.15.1",
"description": "3D visualization library",
"author": "k3d team",
"main": "src/index.js",
Expand Down
36 changes: 20 additions & 16 deletions js/src/core/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ const fflate = require('fflate');
const msgpack = require('msgpack-lite');

const LilGUI = require('lil-gui').GUI;
const { viewModes } = require('./lib/viewMode');
const {viewModes} = require('./lib/viewMode');
const _ = require('../lodash');
const { cameraModes } = require('./lib/cameraMode');
const {cameraModes} = require('./lib/cameraMode');
const loader = require('./lib/Loader');
const serialize = require('./lib/helpers/serialize');
const screenshot = require('./lib/screenshot');
const snapshot = require('./lib/snapshot');
const resetCameraGUI = require('./lib/resetCamera');
const detachWindowGUI = require('./lib/detachWindow');
const fullscreen = require('./lib/fullscreen');
const { viewModeGUI } = require('./lib/viewMode');
const { cameraModeGUI } = require('./lib/cameraMode');
const {viewModeGUI} = require('./lib/viewMode');
const {cameraModeGUI} = require('./lib/cameraMode');
const manipulate = require('./lib/manipulate');
const { getColorLegend } = require('./lib/colorMapLegend');
const {getColorLegend} = require('./lib/colorMapLegend');
const objectsGUIProvider = require('./lib/objectsGUIprovider');
const clippingPlanesGUIProvider = require('./lib/clippingPlanesGUIProvider');
const timeSeries = require('./lib/timeSeries');
const { base64ToArrayBuffer } = require('./lib/helpers/buffer');
const {base64ToArrayBuffer} = require('./lib/helpers/buffer');

const MsgpackCodec = msgpack.createCodec({ preset: true });
const MsgpackCodec = msgpack.createCodec({preset: true});

const Float16Array = require('./lib/helpers/float16Array');

Expand Down Expand Up @@ -909,7 +909,10 @@ function K3D(provider, targetDOMNode, parameters) {
// nothing
}

world.K3DObjects.add(K3DObject);
// skip non-webgl objects
if (object.type !== 'Text' && object.type !== 'Text2d') {
world.K3DObjects.add(K3DObject);
}

objectIndex += 1;

Expand Down Expand Up @@ -1047,7 +1050,7 @@ function K3D(provider, targetDOMNode, parameters) {
return Promise.resolve(true);
}

const data = { objects: [json] };
const data = {objects: [json]};

if (changes !== null) {
data.changes = [changes];
Expand Down Expand Up @@ -1144,9 +1147,9 @@ function K3D(provider, targetDOMNode, parameters) {
chunkList,
plot,
},
{ codec: MsgpackCodec },
{codec: MsgpackCodec},
),
{ level: compressionLevel },
{level: compressionLevel},
);
};

Expand All @@ -1160,7 +1163,7 @@ function K3D(provider, targetDOMNode, parameters) {
}

if (data instanceof Uint8Array) {
data = msgpack.decode(data, { codec: MsgpackCodec });
data = msgpack.decode(data, {codec: MsgpackCodec});
}

Object.keys(data.chunkList).forEach((k) => {
Expand All @@ -1179,7 +1182,7 @@ function K3D(provider, targetDOMNode, parameters) {
});
});

return self.load({ objects: data.objects }).then(() => self.refreshAfterObjectsChange(
return self.load({objects: data.objects}).then(() => self.refreshAfterObjectsChange(
false,
true,
));
Expand All @@ -1206,10 +1209,11 @@ function K3D(provider, targetDOMNode, parameters) {
}
this.autoRendering = false;

world.K3DObjects.children.forEach((obj) => {
removeObjectFromScene(obj.K3DIdentifier);
delete world.ObjectsListJson[obj.K3DIdentifier];
Object.keys(world.ObjectsListJson).forEach(function (K3DIdentifier) {
removeObjectFromScene(K3DIdentifier);
delete world.ObjectsListJson[K3DIdentifier];
});

world.cleanup();

if (fpsMeter) {
Expand Down
Loading

0 comments on commit 61d7652

Please sign in to comment.