Skip to content

Commit

Permalink
Merge pull request #59 from jpmorganchase/dep-updates
Browse files Browse the repository at this point in the history
Dep updates
  • Loading branch information
dsaffo authored Dec 11, 2024
2 parents 9598881 + 1b7bb7a commit 6389e48
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 42 deletions.
8 changes: 6 additions & 2 deletions anu-examples/examples/FirstSteps/Box.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
// Copyright : J.P. Morgan Chase & Co.

import * as anu from '@jpmorganchase/anu' //import anu, this project is using a local import of babylon js located at ../babylonjs-anu this may not be the latest version and is used for simplicity.
import { Scene, HemisphericLight, ArcRotateCamera, Vector3, Mesh, TransformNode} from "@babylonjs/core";
import { Scene, HemisphericLight, ArcRotateCamera, Vector3 } from "@babylonjs/core";

//create and export a function that takes a babylon engine and returns a scene
export const box = function(engine){

const scene = new Scene(engine)

console.log(scene.getEngine().constructor.LastCreatedScene)

new HemisphericLight('light1', new Vector3(0, 10, 0), scene)

const camera = new ArcRotateCamera("Camera", -(Math.PI / 4) * 3, Math.PI / 4, 10, new Vector3(0, 0, 0), scene);
camera.attachControl(true)

let box = anu.create('box', 'ourBox', {size: 2}, [{count: 2}]);
let box = anu.create('box', 'ourBox', {}, [{}]);



return scene;
};
2 changes: 1 addition & 1 deletion anu-examples/examples/ScatterPlots/Scatterplot3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const scatterplot3D = function(engine){

//This series of chained methods will create our visualization
//Using our CoT as a parent we use bind to create sphere meshes for each row of our data
let spheres = chart.bind('sphere', {diameter: 0.05}, iris)
let spheres = anu.bind('sphere', {diameter: 0.05}, iris)
.positionX((d) => scaleX(d.sepalLength)) //most selection methods can either be passed a raw value, or a function that will return the correct value of the attribute
.positionY((d) => scaleY(d.petalLength)) //When you pass a function the method will pass the data associated with the mesh as JSON and the index of the data (d,i)
.positionZ((d) => scaleZ(d.sepalWidth)) //So we create a function that takes param d and since we know the keys of the data can pass d.<key> into our function that returns an int
Expand Down
2 changes: 1 addition & 1 deletion anu-examples/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//Contains the styles for our page, currently setting body,app div, and canvas to 100% h&w
import './style.css'
import { Engine, Color3, WebXRFeatureName, Scene, WebXRHandTracking, Vector3, ReflectiveShadowMap, GIRSMManager} from '@babylonjs/core';
import { Engine, Color3, WebXRFeatureName, Vector3} from '@babylonjs/core';
import { Inspector } from '@babylonjs/inspector';

//Import all of babylonjs, you most likely want to import individual methods as needed
Expand Down
1 change: 1 addition & 0 deletions anu-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@babylonjs/core": "^7.26.2",
"@babylonjs/gui": "^7.26.2",
"@babylonjs/inspector": "^7.26.2",
"@jpmorganchase/anu": "file:..",
"d3": "^7.6.1",
"d3-force-3d": "^3.0.5",
"simplify-3d": "^1.0.0",
Expand Down
19 changes: 19 additions & 0 deletions anu-examples/vitest.workspace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineWorkspace } from 'vitest/config'

export default defineWorkspace([
// If you want to keep running your existing tests in Node.js, uncomment the next line.
// 'vite.config.js',
{
extends: 'vite.config.js',
test: {
browser: {
enabled: true,
name: 'chromium',
provider: 'playwright',
// https://playwright.dev
providerOptions: {},
viewport: { width: 1920, height: 1080}
},
},
},
])
3 changes: 2 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"vue": "^3.3.4"
},
"dependencies": {
"@babylonjs/core": "^7.1.0",
"@babylonjs/gui": "^7.1.0",
"@babylonjs/inspector": "^7.1.0",
"@babylonjs/loaders": "^7.1.0",
"@jpmorganchase/anu": "0.1.3",
"@jpmorganchase/anu": "0.1.5",
"d3": "^7.9.0",
"d3-force-3d": "^3.0.5",
"vite-plugin-dynamic-import": "^1.5.0",
Expand Down
27 changes: 22 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 21 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jpmorganchase/anu",
"version": "0.1.4",
"version": "0.1.5",
"description": "",
"type": "module",
"files": [
Expand Down Expand Up @@ -30,9 +30,26 @@
"url": "git@github.com:jpmorganchase/anu.git"
},
"keywords": [],
"author": "",
"author": "David Saffo",
"license": "Apache-2.0",
"peerDependencies": {
"@babylonjs/core": "5.x || 6.x || 7.x"
},
"dependencies": {
"babylon-msdf-text": "^0.0.4",
"chroma-js": "^2.4.2",
"d3-geo": "^3.1.1",
"d3-geo-projection": "^4.0.0",
"d3-scale": "^4.0.2",
"earcut": "^2.2.4",
"lodash-es": "^4.17.21",
"ol": "^7.3.0",
"topojson-client": "^3.1.0",
"topojson-server": "^3.0.1",
"topojson-simplify": "^3.0.3"
},
"devDependencies": {
"@babylonjs/core": "^7.26.2",
"@types/chroma-js": "^2.4.3",
"@types/d3": "^7.4.0",
"@types/earcut": "^2.1.4",
Expand All @@ -48,20 +65,7 @@
"typedoc-plugin-markdown": "^3.16.0",
"typescript": "^5.4.3",
"vite": "^5.2.8",
"vite-plugin-dts": "^2.3.0"
},
"dependencies": {
"@babylonjs/core": "^7.26.2",
"babylon-msdf-text": "^0.0.4",
"chroma-js": "^2.4.2",
"d3-geo": "^3.1.1",
"d3-geo-projection": "^4.0.0",
"d3-scale": "^4.0.2",
"earcut": "^2.2.4",
"lodash-es": "^4.17.21",
"ol": "^7.3.0",
"topojson-client": "^3.1.0",
"topojson-server": "^3.0.1",
"topojson-simplify": "^3.0.3"
"vite-plugin-dts": "^2.3.0",
"vite-plugin-externalize-deps": "^0.8.0"
}
}
9 changes: 8 additions & 1 deletion src/bind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
// Copyright : J.P. Morgan Chase & Co.

import { Node, ActionManager, Tags, Mesh, Scene, InstancedMesh, Matrix } from '@babylonjs/core';

// import { Scene } from '@babylonjs/core/scene';
// import { Node } from '@babylonjs/core/node';
// import { Mesh, InstancedMesh } from '@babylonjs/core/Meshes';
// import { Matrix } from '@babylonjs/core';
// import { ActionManager } from '@babylonjs/core/Actions/actionManager';
// import { Tags } from '@babylonjs/core/Misc/tags';

import { Selection } from './index';
import { create, MeshTypes } from './create';

Expand All @@ -24,7 +32,6 @@ export function bind<MeshType extends keyof MeshTypes>(shape: MeshType, options?
var mesh = create(shape, shape, options, element, scene);
meshes.push(mesh);
});

return new Selection(meshes, meshes[0].getScene());
}

Expand Down
4 changes: 2 additions & 2 deletions src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ interface StringByAny {
[key: string]: any;
}

function createCOT(name: string, options: object, scene: Scene) {
function createCOT(name: string, options: object, scene?: Scene) {
return new TransformNode(name, scene);
}

function createGL(name: string, options: GreasedLineMeshBuilderOptions, scene: Scene){
function createGL(name: string, options: GreasedLineMeshBuilderOptions, scene?: Scene){
return CreateGreasedLine(name, options, {}, scene);
}

Expand Down
3 changes: 1 addition & 2 deletions src/prefabs/Axis/Axis.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright : J.P. Morgan Chase & Co.

import { Texture, TransformNode, Node, Mesh } from '@babylonjs/core';
import { Texture, TransformNode, Node } from '@babylonjs/core';
import { Scene } from '@babylonjs/core/scene';
import { Selection } from '../../selection';
import { labelAlt } from './label';
import { backgroundAlt } from './background';
import { grid } from './grid';
import { domain } from './domain';
import png from '../../assets/roboto-regular.png';
import { Prefab } from '../Prefab';

interface AxisOptions {
parent?: Node | Selection;
Expand Down
2 changes: 1 addition & 1 deletion src/prefabs/Axis/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function labelAlt(
let scaleMultiplier = bounds.extendSize.y + bounds.extendSize.x + bounds.extendSize.z;
let textHeight = scaleMultiplier * 0.025

console.log(scaleMultiplier, bounds);
//console.log(scaleMultiplier, bounds);

if (this.options.scale?.x != undefined) {
let ticks; //Not every d3 scale supports the ticks function, for those that don't default to using domain
Expand Down
3 changes: 2 additions & 1 deletion src/select.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright : J.P. Morgan Chase & Co.

import { Node, Tags } from '@babylonjs/core';
import { Node } from '@babylonjs/core/node';
import { Scene } from '@babylonjs/core/scene';
import { Tags } from '@babylonjs/core/Misc/tags';
import { Selection } from './selection/index';

/**
Expand Down
1 change: 0 additions & 1 deletion src/selection/property/thin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ export function thinInstanceScalingFor(this: Selection, method: (d: any, n: Node
let data = node.metadata.data ??={}
data.forEach((e, j) => {
if (method(e, node, j)) {
console.log('hello')
let evaluated = value instanceof Function ? value(e, node, j) : value
let previousMatrix = node.thinInstanceGetWorldMatrices()[j];
let matrix = Matrix.ComposeToRef(evaluated, Quaternion.FromRotationMatrix(previousMatrix.getRotationMatrix()), previousMatrix.getTranslation(), previousMatrix)
Expand Down
20 changes: 13 additions & 7 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// vite.config.js
import { rollup } from 'd3';
import { resolve } from 'path'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts';
import { externalizeDeps } from "vite-plugin-externalize-deps";

export default defineConfig({
build: {
Expand All @@ -13,15 +15,19 @@ export default defineConfig({
fileName: 'anu',
},
rollupOptions: {
external: ["@babylonjs/core"],
external: [
"@babylonjs/core",
"ol"
],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
"@babylonjs/core": '@babylonjs/core',
"@babylonjs/core": "BABYLON",
"ol": "ol"
},
},
},
},
},
plugins: [dts()],
})
plugins: [dts({rollupTypes: true}),
externalizeDeps(),
],
});

0 comments on commit 6389e48

Please sign in to comment.