@threlte/core
Advanced tools
Comparing version 8.0.0-next.19 to 8.0.0-next.20
@@ -6,13 +6,5 @@ import { onDestroy } from 'svelte'; | ||
import { createParentObject3DContext, useParentObject3D } from '../../../context/fragments/parentObject3D'; | ||
import { isInstanceOf } from '../../../lib/isInstanceOf'; | ||
import { watch } from '../../../lib/storeUtils'; | ||
import { resolvePropertyPath } from './resolvePropertyPath'; | ||
const isObject3D = (ref) => { | ||
return typeof ref === 'object' && ref !== null && 'isObject3D' in ref; | ||
}; | ||
const isMaterial = (ref) => { | ||
return typeof ref === 'object' && ref !== null && 'isMaterial' in ref; | ||
}; | ||
const isGeometry = (ref) => { | ||
return (typeof ref === 'object' && ref !== null && ('isGeometry' in ref || 'isBufferGeometry' in ref)); | ||
}; | ||
const isObject = (ref) => { | ||
@@ -43,3 +35,3 @@ return typeof ref === 'object' && ref !== null; | ||
} | ||
else if (isObject3D(attach) && isObject3D(ref)) { | ||
else if (isInstanceOf(attach, 'Object3D') && isInstanceOf(ref, 'Object3D')) { | ||
detachFn = () => attach?.remove(ref); | ||
@@ -59,3 +51,3 @@ // Add to parent Object3D | ||
// Auto attach | ||
if (isObject3D(ref)) { | ||
if (isInstanceOf(ref, 'Object3D')) { | ||
// Build detach function | ||
@@ -68,6 +60,6 @@ detachFn = () => parentObject3D?.remove(ref); | ||
// Auto-attach to parent material or geometry | ||
if (isMaterial(ref)) { | ||
if (isInstanceOf(ref, 'Material')) { | ||
parent['material'] = ref; | ||
} | ||
else if (isGeometry(ref)) { | ||
else if (isInstanceOf(ref, 'BufferGeometry')) { | ||
parent['geometry'] = ref; | ||
@@ -84,3 +76,3 @@ } | ||
currentRef.set(value); | ||
if (isObject3D(value)) { | ||
if (isInstanceOf(value, 'Object3D')) { | ||
object3D.set(value); | ||
@@ -87,0 +79,0 @@ } |
import { writable } from 'svelte/store'; | ||
import { useThrelte } from '../../../context/compounds/useThrelte'; | ||
import { watch } from '../../../lib/storeUtils'; | ||
const isOrthographicCamera = (value) => { | ||
return typeof value === 'object' && value !== null && 'isOrthographicCamera' in value; | ||
}; | ||
const isPerspectiveCamera = (value) => { | ||
return typeof value === 'object' && value !== null && 'isPerspectiveCamera' in value; | ||
}; | ||
import { isInstanceOf } from '../../../lib/isInstanceOf'; | ||
const isPerspectiveOrOrthographicCamera = (value) => { | ||
return isPerspectiveCamera(value) || isOrthographicCamera(value); | ||
return isInstanceOf(value, 'PerspectiveCamera') || isInstanceOf(value, 'OrthographicCamera'); | ||
}; | ||
@@ -27,3 +22,3 @@ export const useCamera = () => { | ||
return; | ||
if (isOrthographicCamera(ref)) { | ||
if (isInstanceOf(ref, 'OrthographicCamera')) { | ||
ref.left = size.width / -2; | ||
@@ -37,3 +32,3 @@ ref.right = size.width / 2; | ||
} | ||
else if (isPerspectiveCamera(ref)) { | ||
else if (isInstanceOf(ref, 'PerspectiveCamera')) { | ||
ref.aspect = size.width / size.height; | ||
@@ -40,0 +35,0 @@ ref.updateProjectionMatrix(); |
@@ -1,6 +0,2 @@ | ||
import type { Object3D } from 'three'; | ||
import type { MaybeInstance } from '../types'; | ||
import type { DisposableThreeObject } from '../../../types'; | ||
export declare const determineRef: <Type>(is: unknown, args: unknown) => MaybeInstance<Type>; | ||
export declare const extendsObject3D: (object: any) => object is Object3D<import("three").Object3DEventMap>; | ||
export declare const isDisposableObject: (object: any) => object is DisposableThreeObject; |
@@ -23,7 +23,1 @@ const classRegex = /^\s*class\s+/; | ||
}; | ||
export const extendsObject3D = (object) => { | ||
return 'isObject3D' in object; | ||
}; | ||
export const isDisposableObject = (object) => { | ||
return 'dispose' in object; | ||
}; |
@@ -31,3 +31,4 @@ export declare const VERSION = 8; | ||
export { currentWritable, memoize, watch, type CurrentWritable } from './lib/storeUtils'; | ||
export { isInstanceOf } from './lib/isInstanceOf'; | ||
export type { HierarchicalObjectProperties } from './internal/HierarchicalObject.svelte'; | ||
export type { SceneGraphObjectProperties } from './internal/SceneGraphObject.svelte'; |
@@ -33,1 +33,2 @@ export const VERSION = 8; | ||
export { currentWritable, memoize, watch } from './lib/storeUtils'; | ||
export { isInstanceOf } from './lib/isInstanceOf'; |
{ | ||
"name": "@threlte/core", | ||
"version": "8.0.0-next.19", | ||
"version": "8.0.0-next.20", | ||
"author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
207957
99
4990