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

update-in-place for three r168 #305

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions libs/ff-scene/source/components/CCamera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* License: MIT
*/

import { Vector3, Euler, Quaternion, EulerOrder } from "three";
import { Vector3, Euler, Quaternion, EulerOrder, Matrix4 } from "three";

import { Node, types } from "@ff/graph/Component";

Expand Down Expand Up @@ -107,7 +107,7 @@ export default class CCamera extends CObject3D
* Updating the properties then also updates the matrix of the internal universal camera object.
* @param matrix A 4x4 transform matrix. If omitted, properties are updated from the matrix of the internal camera.
*/
setPropertiesFromMatrix(matrix?: THREE.Matrix4)
setPropertiesFromMatrix(matrix?: Matrix4)
{
const silent = !matrix;
matrix = matrix || this.object3D.matrix;
Expand Down
30 changes: 15 additions & 15 deletions libs/ff-scene/source/components/CObject3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface IObject3DObjectEvent extends ITypedEvent<"object">
}

/**
* Base class for drawable components. Wraps a THREE.Object3D based instance.
* Base class for drawable components. Wraps a Object3D based instance.
* If component is added to a node together with a [[Transform]] component,
* it is automatically added as a child to the transform.
*/
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class CObject3D extends Component implements ICObject3D
outs = this.addOutputs(CObject3D.object3DOuts);


private _object3D: THREE.Object3D = null;
private _object3D: Object3D = null;
private _isPickable = false;

constructor(node: Node, id: string)
Expand Down Expand Up @@ -91,17 +91,17 @@ export default class CObject3D extends Component implements ICObject3D
const transform = this.transform;
return transform ? transform.getParentComponent(CScene, true) : undefined;
}
/** The underlying [[THREE.Object3D]] of this component. */
get object3D(): THREE.Object3D | null {
/** The underlying [[Object3D]] of this component. */
get object3D(): Object3D | null {
return this._object3D;
}

/**
* Assigns a [[THREE.Object3D]] to this component. The object automatically becomes a child
* Assigns a [[Object3D]] to this component. The object automatically becomes a child
* of the parent component's object.
* @param object
*/
set object3D(object: THREE.Object3D)
set object3D(object: Object3D)
{
const currentObject = this._object3D;
if (currentObject) {
Expand Down Expand Up @@ -254,33 +254,33 @@ export default class CObject3D extends Component implements ICObject3D
return true;
}

protected onAddToParent(parent: THREE.Object3D)
protected onAddToParent(parent: Object3D)
{
parent.add(this._object3D);
}

protected onRemoveFromParent(parent: THREE.Object3D)
protected onRemoveFromParent(parent: Object3D)
{
parent.remove(this._object3D);
}

/**
* Adds a [[THREE.Object3D]] as a child to this component's object.
* Adds a [[Object3D]] as a child to this component's object.
* Registers the object with the picking service to make it pickable.
* @param object
*/
protected addObject3D(object: THREE.Object3D)
protected addObject3D(object: Object3D)
{
this._object3D.add(object);
this.registerPickableObject3D(object, true);
}

/**
* Removes a [[THREE.Object3D]] child from this component's object.
* Removes a [[Object3D]] child from this component's object.
* Also unregisters the object from the picking service.
* @param object
*/
protected removeObject3D(object: THREE.Object3D)
protected removeObject3D(object: Object3D)
{
this.unregisterPickableObject3D(object, true);
this._object3D.remove(object);
Expand All @@ -292,7 +292,7 @@ export default class CObject3D extends Component implements ICObject3D
* @param object
* @param recursive
*/
protected registerPickableObject3D(object: THREE.Object3D, recursive: boolean)
protected registerPickableObject3D(object: Object3D, recursive: boolean)
{
GPUPicker.add(object, recursive);
}
Expand All @@ -303,14 +303,14 @@ export default class CObject3D extends Component implements ICObject3D
* @param object
* @param recursive
*/
protected unregisterPickableObject3D(object: THREE.Object3D, recursive: boolean)
protected unregisterPickableObject3D(object: Object3D, recursive: boolean)
{
GPUPicker.remove(object, recursive);
}

private _onParent(event: IComponentEvent<ICObject3D>)
{
// add this THREE.Object3D to the parent THREE.Object3D
// add this Object3D to the parent Object3D
if (this._object3D && !this._object3D.parent && event.add) {
this.onAddToParent(event.object.object3D);
}
Expand Down
7 changes: 2 additions & 5 deletions libs/ff-three/source/Floor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export interface IFloorMaterialParameters extends MeshPhongMaterialParameters

export class FloorMaterial extends MeshPhongMaterial
{
isMeshPhongMaterial: boolean;
isFloorMaterial: boolean;
readonly isMeshPhongMaterial = true;
readonly isFloorMaterial = true;

uniforms: {
};
Expand All @@ -69,9 +69,6 @@ export class FloorMaterial extends MeshPhongMaterial

this.type = "FloorMaterial";

this.isMeshPhongMaterial = true;
this.isFloorMaterial = true;

this.defines = {};
this.uniforms = UniformsUtils.merge([
ShaderLib.phong.uniforms
Expand Down
6 changes: 3 additions & 3 deletions libs/ff-three/source/Grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export interface IGridProps
size: number;
mainDivisions: number;
subDivisions: number;
mainColor: THREE.Color | string | number;
subColor: THREE.Color | string | number;
mainColor: Color | string | number;
subColor: Color | string | number;
}

export default class Grid extends LineSegments
Expand Down Expand Up @@ -51,7 +51,7 @@ export default class Grid extends LineSegments
this.geometry = Grid.generate(props);
}

protected static generate(props: IGridProps): THREE.BufferGeometry
protected static generate(props: IGridProps): BufferGeometry
{
const mainColor = new Color(props.mainColor as any);
const subColor = new Color(props.subColor as any);
Expand Down
3 changes: 2 additions & 1 deletion libs/ff-three/source/HTMLSprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Camera,
Vector2,
Vector3,
Object3DEventMap,
} from "three";

import CustomElement, { customElement, html } from "@ff/ui/CustomElement";
Expand All @@ -31,7 +32,7 @@ export enum EQuadrant { TopRight, TopLeft, BottomLeft, BottomRight }
* A Three.js Object representing a 3D renderable part and a 2D (HTML) part.
* HTML sprites should have a [[HTMLSpriteGroup]] as their parent.
*/
export default class HTMLSprite extends Object3D
export default class HTMLSprite<EventMap extends Object3DEventMap = Object3DEventMap> extends Object3D<EventMap>
{
readonly isHTMLSprite = true;

Expand Down
26 changes: 13 additions & 13 deletions libs/ff-three/source/UniversalCamera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default class UniversalCamera extends Camera
// TODO: Implement
}

moveToView(boundingBox: THREE.Box3)
moveToView(boundingBox: Box3)
{
this.updateMatrixWorld(false);
_box.copy(boundingBox);
Expand Down Expand Up @@ -278,20 +278,20 @@ export default class UniversalCamera extends Camera
toJSON(meta)
{
const data = super.toJSON(meta);

data.object.fov = this.fov;
data.object.size = this.size;
data.object.aspect = this.aspect;
data.object.zoom = this.zoom;
data.object.near = this.near;
data.object.far = this.far;

data.object.focus = this.focus;
data.object.filmGauge = this.filmGauge;
data.object.filmOffset = this.filmOffset;
Object.assign(data.object, {
fov: this.fov,
size: this.size,
aspect: this.aspect,
zoom: this.zoom,
near: this.near,
far: this.far,
focus: this.focus,
filmGauge: this.filmGauge,
filmOffset: this.filmOffset,
});

if (this.view !== null) {
data.object.view = Object.assign({}, this.view);
(data.object as any).view = Object.assign({}, this.view);
}

return data;
Expand Down
Loading