ecsy-babylon
Advanced tools
Comparing version 0.4.2 to 0.5.0
@@ -0,1 +1,15 @@ | ||
## v0.5.0 (2020-09-21) | ||
#### :boom: Breaking Change | ||
* [#276](https://github.com/kaliber5/ecsy-babylon/pull/276) Don't add default camera to scene ([@simonihmig](https://github.com/simonihmig)) | ||
#### :rocket: Enhancement | ||
* [#276](https://github.com/kaliber5/ecsy-babylon/pull/276) Don't add default camera to scene ([@simonihmig](https://github.com/simonihmig)) | ||
#### :bug: Bug Fix | ||
* [#275](https://github.com/kaliber5/ecsy-babylon/pull/275) Fix actions not working when ray support has not been enabled due to tree-shaking ([@simonihmig](https://github.com/simonihmig)) | ||
#### Committers: 1 | ||
- Simon Ihmig ([@simonihmig](https://github.com/simonihmig)) | ||
## v0.4.2 (2020-09-16) | ||
@@ -2,0 +16,0 @@ |
import { Scene } from '@babylonjs/core/scene'; | ||
import { Engine } from '@babylonjs/core/Engines/engine'; | ||
import { Component, ComponentSchema, World } from 'ecsy'; | ||
import { Camera } from '@babylonjs/core/Cameras/camera'; | ||
import { ShadowGenerator } from '@babylonjs/core/Lights/Shadows/shadowGenerator'; | ||
@@ -9,3 +8,2 @@ export default class BabylonCore extends Component<BabylonCore> { | ||
canvas: HTMLCanvasElement; | ||
defaultCamera: Camera; | ||
engine: Engine; | ||
@@ -12,0 +10,0 @@ scene: Scene; |
@@ -15,5 +15,2 @@ import { Component, Types } from 'ecsy'; | ||
}, | ||
defaultCamera: { | ||
type: Types.Ref, | ||
}, | ||
engine: { | ||
@@ -20,0 +17,0 @@ type: Types.Ref, |
@@ -12,2 +12,3 @@ import { Component, ComponentSchema } from 'ecsy'; | ||
fov?: number; | ||
fovMode?: number; | ||
static schema: ComponentSchema; | ||
@@ -14,0 +15,0 @@ } |
@@ -11,2 +11,3 @@ import { Component, Types } from 'ecsy'; | ||
fov: { type: Types.Number, default: undefined }, | ||
fovMode: { type: Types.Number, default: undefined }, | ||
}; | ||
@@ -13,0 +14,0 @@ export class AbstractTargetCamera extends Component { |
{ | ||
"name": "ecsy-babylon", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
import { Entity } from 'ecsy'; | ||
import { Action, Mesh } from '../components'; | ||
import SystemWithCore from '../-private/systems/with-core'; | ||
import '@babylonjs/core/Culling/ray'; | ||
export default class ActionSystem extends SystemWithCore { | ||
@@ -5,0 +6,0 @@ execute(): void; |
@@ -7,2 +7,3 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ | ||
import { ExecuteCodeAction } from '@babylonjs/core/Actions/directActions'; | ||
import '@babylonjs/core/Culling/ray'; // this has a side effect of making the scene support picks/rays, see https://doc.babylonjs.com/features/es6_support#side-effects | ||
const TRIGGER = { | ||
@@ -9,0 +10,0 @@ pick: ActionManager.OnPickTrigger, |
import { System } from 'ecsy'; | ||
import { BabylonCore } from '../components'; | ||
import { Scene } from '@babylonjs/core/scene'; | ||
import { Vector3 } from '@babylonjs/core/Maths/math.vector'; | ||
import { Engine } from '@babylonjs/core/Engines/engine'; | ||
import { FreeCamera } from '@babylonjs/core/Cameras/freeCamera'; | ||
export default class BabylonSystem extends System { | ||
@@ -17,7 +15,8 @@ execute() { | ||
core.scene = new Scene(core.engine); | ||
core.defaultCamera = new FreeCamera('defaultCamera', new Vector3(0, 0, -10), core.scene); | ||
core.defaultCamera.attachControl(core.canvas, false); | ||
this.listener = function () { | ||
this.engine.resize(); | ||
}.bind({ engine: core.engine }); | ||
// @todo do we really want to do this here? Or should we delegate the responsibility ot the consumer? | ||
// For example the canvas might need to even react to resizing the canvas *element*, not just the | ||
// while window, i.e. we would have to use a ResizeObserver | ||
window.addEventListener('resize', this.listener); | ||
@@ -24,0 +23,0 @@ const startTime = window.performance.now(); |
@@ -16,9 +16,10 @@ import { Camera, TransformNode } from '../components'; | ||
const { scene, canvas } = this.core; | ||
const { value: instance } = entity.getComponent(Camera); | ||
assert('Failed to add Camera, no camera instance found.', instance); | ||
scene.activeCamera = instance; | ||
scene.activeCamera.attachControl(canvas, false); | ||
const { value: camera } = entity.getComponent(Camera); | ||
assert('Failed to add Camera, no camera instance found.', camera); | ||
scene.addCamera(camera); | ||
scene.activeCamera = camera; | ||
camera.attachControl(canvas, false); | ||
const transformNodeComponent = entity.getComponent(TransformNode); | ||
assert('TransformNode needed for cameras, add Parent component to fix', transformNodeComponent); | ||
instance.parent = transformNodeComponent.value; | ||
camera.parent = transformNodeComponent.value; | ||
} | ||
@@ -33,15 +34,6 @@ update(entity) { | ||
remove(entity) { | ||
var _a; | ||
assert('CameraSystem needs BabylonCoreComponent', this.core); | ||
const { scene, canvas, defaultCamera } = this.core; | ||
const cameraComponent = entity.getRemovedComponent(Camera); | ||
// TODO: We might need something smarter here in the future, what if there's multiple camera entities? | ||
// set defaultCamera as current active camera if it exists | ||
scene.activeCamera = defaultCamera || null; | ||
if (scene.activeCamera) { | ||
// restore control if there is still an active camera | ||
scene.activeCamera.attachControl(canvas, false); | ||
} | ||
if (cameraComponent.value) { | ||
cameraComponent.value.dispose(); | ||
} | ||
(_a = cameraComponent.value) === null || _a === void 0 ? void 0 : _a.dispose(); | ||
} | ||
@@ -48,0 +40,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
419963
5641