Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: three dependency typing #5

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 17 additions & 24 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@
"rete": "^2.0.1",
"rete-area-plugin": "^2.0.0",
"rete-render-utils": "^2.0.0",
"three": ">= 0.152.2 < 0.158.0"
"three": ">= 0.152.2 < 0.157.0"
},
"devDependencies": {
"@rollup/plugin-alias": "^5.0.0",
"@rollup/plugin-commonjs": "^25.0.0",
"@types/three": "^0.152.0",
"@types/three": "^0.156.0",
"parse-svg-path": "^0.1.2",
"rete": "^2.0.1",
"rete-area-plugin": "^2.0.0",
"rete-cli": "^1.0.1",
"rete-render-utils": "^2.0.0",
"svg-path-contours": "^2.0.0",
"three": "^0.152.2"
"three": "^0.156.1"
},
"dependencies": {
"@babel/runtime": "^7.21.0"
Expand Down
3 changes: 2 additions & 1 deletion src/area.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Object3D } from 'three'

Check warning on line 1 in src/area.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Run autofix to sort these imports!

Check warning on line 1 in src/area.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Run autofix to sort these imports!
import { Content } from './content'
import { HybridScene } from './scene'
import { orbitControlsRestrictor } from './scene/OrbitControls'
Expand Down Expand Up @@ -27,7 +28,7 @@

content: Content<Scope>

constructor(private container: HTMLElement, scene: HybridScene<Scope> | null, private scope: Scope, private events: Events, private guards: Guards) {

Check warning on line 31 in src/area.ts

View workflow job for this annotation

GitHub Actions / ci / ci

This line has a length of 151. Maximum allowed is 120

Check warning on line 31 in src/area.ts

View workflow job for this annotation

GitHub Actions / ci / ci

This line has a length of 151. Maximum allowed is 120
this.scene = scene || new HybridScene(this.container)
this.content = new Content(this.scene, scope, element => this.events.reordered(element))

Expand All @@ -49,7 +50,7 @@
/**
* Get the canvas in form of Object3D for the current scope
*/
public getCanvas() {
public getCanvas(): Object3D | undefined {
return this.scene.canvases.get(this.scope)
}

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/forms/connection/geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { BufferGeometry, PlaneGeometry, Vector2 } from 'three'
* @returns Connection geometry
*/
// eslint-disable-next-line max-statements
export function createClassicConnectionGeometry(path: string, width: number) {
export function createClassicConnectionGeometry(path: string, width: number): BufferGeometry {
const segments = contours(parse(path)) as [number, number][][]
const points = segments.map(segment => segment.map(([x, y]) => ({ x, y }))).flat()
const geometry: BufferGeometry = new PlaneGeometry(100, 10, points.length - 1, 1)
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/forms/node/geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @returns Node geometry
*/
// eslint-disable-next-line max-statements
export function createClassicNodeGeometry(size: Size, params?: Params) {
export function createClassicNodeGeometry(size: Size, params?: Params): BufferGeometry {
const {
borderRadius = 10,
inputsOffset = 15.5,
Expand All @@ -44,7 +44,7 @@
const extra: BufferGeometry[] = []

if ('inputs' in size) {
const inputs = Object.entries((size as any).inputs).length

Check warning on line 47 in src/extensions/forms/node/geometry.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 47 in src/extensions/forms/node/geometry.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

for (let index = 0; index < inputs; index++) {
const geom = circle.clone()
Expand Down
6 changes: 4 additions & 2 deletions src/scene/Drag/DragControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import {

import { findTop, ObjectHTML } from '../ObjectHTML'

type DefaultObject3D = Object3D

const raycaster = new Raycaster()

class DragControls extends EventDispatcher {
class DragControls extends EventDispatcher<any> {
enabled = true
intersections: Intersection<ObjectHTML>[] = []
selected: Object3D | null = null
hovered: Object3D | null = null
objects = new Set<Object3D>()
objects = new Set<DefaultObject3D>()

private pointer = new Vector2()
private offset = new Vector3()
Expand Down
4 changes: 3 additions & 1 deletion src/scene/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { OrbitControls } from './OrbitControls'

export { DraggableObject3D }

type DefaultObject3D = Object3D

/**
* HybridScene is a wrapper for Three.js Scene with some additional features such as:
* - drag controls
Expand All @@ -20,7 +22,7 @@ export class HybridScene<Scope> {
camera: PerspectiveCamera
renderer: HybridRenderer
root = new Scene()
canvases = new Map<Scope, Object3D>()
canvases = new Map<Scope, DefaultObject3D>()
controls: DragControls
orbit: OrbitControls

Expand Down
Loading