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

merge main #576

Merged
merged 43 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
df25f03
feat: solve math design circular dependency (#485)
yangfengzzz Sep 7, 2021
f064cc8
Revert "feat: solve math design circular dependency (#485)" (#487)
GuoLei1990 Sep 7, 2021
2878bdf
feat: add rotateAxisAngle for Quaternion (#480)
JujieX Sep 7, 2021
7d17191
refactor: delete useless scene raycast (#493)
gz65555 Sep 8, 2021
aea4277
fix: group other uniform block (#504)
zhuxudong Sep 10, 2021
6b86f88
fix(primitivemesh): fix cylinder error (#526)
singlecoder Oct 8, 2021
750be3c
Perf: release gpu command (#503)
zhuxudong Oct 9, 2021
bc9487d
fix: reset clipTime (#530)
luzhuang Oct 9, 2021
365219c
fix: use string replace asset type to extend easily (#520)
gz65555 Oct 12, 2021
159e5a2
Fix/animator (#531)
luzhuang Oct 12, 2021
18909ed
Update README.md
eyworldwide Oct 12, 2021
3085ac8
Fix: cubic interpolation and crossfade bug: From fixed pose to dest p…
luzhuang Oct 12, 2021
b5bd22d
v0.5.3
GuoLei1990 Oct 12, 2021
871c102
v0.5.4
GuoLei1990 Oct 12, 2021
d9ef75d
v0.5.5
GuoLei1990 Oct 12, 2021
e8cc0e1
v0.5.6
GuoLei1990 Oct 12, 2021
3b4a242
fix(2d): opt shader precision (#542)
singlecoder Oct 15, 2021
e36cb48
fix: delete default gl state (#550)
zhuxudong Oct 25, 2021
f757f7f
fix(gl): fix gl error (#555)
singlecoder Oct 26, 2021
e8b3097
v0.5.7
GuoLei1990 Oct 26, 2021
d9832dd
Fix Call EndRender Error (#563)
gz65555 Nov 4, 2021
f571fe0
feat: support skybox with hdr(rgbe) format (#567)
zhuxudong Nov 8, 2021
5c0414e
fix: color space correction (#566)
zhuxudong Nov 8, 2021
adde3a2
fix: bump version (#568)
JujieX Nov 8, 2021
be224b3
feat: change clipTime to normalized as same as transitionTime for mo…
luzhuang Nov 9, 2021
b70ca9f
Update README.md
GuoLei1990 Nov 9, 2021
72761a6
Update README.md
GuoLei1990 Nov 9, 2021
aca8331
Update README.md
GuoLei1990 Nov 9, 2021
72ce686
feat: add method: addEvent overload (#559)
luzhuang Nov 9, 2021
b33681f
feat: support ambient-light replacement (#569)
zhuxudong Nov 9, 2021
3c1065a
Feat/ambient light adapter editor (#570)
zhuxudong Nov 9, 2021
9845181
feat: add getCurrentAnimatorState API and fix crossfade time (#565)
luzhuang Nov 10, 2021
9b695b0
fix: use alipay cdn for physx wasm (#571)
yangfengzzz Nov 10, 2021
00f74cd
add wasm file (#572)
yangfengzzz Nov 10, 2021
97be84a
Fix : the compatibility problem of IOS lower version (#573)
cptbtptpbcptdtptp Nov 10, 2021
b87b09f
Merge branch 'dev/0.6'
GuoLei1990 Nov 10, 2021
f986b98
Merge dev/0.6 branch (#574)
GuoLei1990 Nov 10, 2021
a5a77ce
Merge branch 'main' of github.com:oasis-engine/engine
GuoLei1990 Nov 10, 2021
8ced19e
v0.6.0-alpha.0
GuoLei1990 Nov 10, 2021
11690f3
refactor: fix physics package.json
GuoLei1990 Nov 10, 2021
056cc8d
refactor: fix physics package.json (#575)
GuoLei1990 Nov 10, 2021
7f9f533
Merge branch 'main' of github.com:oasis-engine/engine
GuoLei1990 Nov 10, 2021
9c1e648
v0.6.0-alpha.1
GuoLei1990 Nov 10, 2021
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import { Engine, Scene, Entity } from "oasis-engine";

Everyone is welcome to join us! Whether you find a bug, have a great feature request or you fancy owning a task from the road map feel free to get in touch.

Make sure to read the [Contributing Guide](.github/HOW_TO_CONTRIBUTE.md) before submitting changes.
Make sure to read the [Contributing Guide](.github/HOW_TO_CONTRIBUTE.md) / [贡献指南](https://github.com/oasis-engine/engine/wiki/%E5%A6%82%E4%BD%95%E4%B8%8E%E6%88%91%E4%BB%AC%E5%85%B1%E5%BB%BA-Oasis-%E5%BC%80%E6%BA%90%E4%BA%92%E5%8A%A8%E5%BC%95%E6%93%8E) before submitting changes.

## Build

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"npmClient": "npm",
"version": "0.5.7",
"version": "0.6.0-alpha.1",
"bootstrap": {
"hoist": true
},
Expand Down
4 changes: 2 additions & 2 deletions packages/controls/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oasis-engine/controls",
"version": "0.5.7",
"version": "0.6.0-alpha.1",
"license": "MIT",
"scripts": {
"b:types": "tsc",
Expand All @@ -15,6 +15,6 @@
"types/**/*"
],
"dependencies": {
"oasis-engine": "0.5.7"
"oasis-engine": "0.6.0-alpha.1"
}
}
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oasis-engine/core",
"version": "0.5.7",
"version": "0.6.0-alpha.1",
"license": "MIT",
"main": "dist/main.js",
"module": "dist/module.js",
Expand All @@ -14,9 +14,9 @@
"types/**/*"
],
"dependencies": {
"@oasis-engine/math": "0.5.7"
"@oasis-engine/math": "0.6.0-alpha.1"
},
"devDependencies": {
"@oasis-engine/design": "0.5.7"
"@oasis-engine/design": "0.6.0-alpha.1"
}
}
2 changes: 1 addition & 1 deletion packages/core/src/ComponentsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class ComponentsManager {
const camComps = camera.entity._components;
for (let i = camComps.length - 1; i >= 0; --i) {
const camComp = camComps[i];
(camComp as any).onBeginRender && (camComp as any).onEndRender(camera);
(camComp as any).onEndRender && (camComp as any).onEndRender(camera);
}
}

Expand Down
26 changes: 23 additions & 3 deletions packages/core/src/Scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export class Scene extends EngineObject {

/** Scene name. */
name: string;
/** Ambient light. */
ambientLight: AmbientLight;

/** The background of the scene. */
readonly background: Background = new Background(this._engine);
Expand All @@ -37,6 +35,28 @@ export class Scene extends EngineObject {

private _destroyed: boolean = false;
private _rootEntities: Entity[] = [];
private _ambientLight: AmbientLight;

/**
* Ambient light.
*/
get ambientLight(): AmbientLight {
return this._ambientLight;
}

set ambientLight(value: AmbientLight) {
if (!value) {
Logger.warn("The scene must have one ambient light");
return;
}

const lastAmbientLight = this._ambientLight;
if (lastAmbientLight !== value) {
lastAmbientLight && lastAmbientLight._setScene(null);
value._setScene(this);
this._ambientLight = value;
}
}

/**
* Count of root entities.
Expand Down Expand Up @@ -71,7 +91,7 @@ export class Scene extends EngineObject {
const shaderData = this.shaderData;
Scene.sceneFeatureManager.addObject(this);
shaderData._addRefCount(1);
this.ambientLight = new AmbientLight(this);
this.ambientLight = new AmbientLight();
}

/**
Expand Down
23 changes: 21 additions & 2 deletions packages/core/src/animation/AnimationClip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,31 @@ export class AnimationClip extends Motion {
super();
}

/**
* Adds an animation event to the clip.
* @param functionName - The name of the method called in the script
* @param time - The time when the event be triggered
* @param parameter - The parameter that is stored in the event and will be sent to the function
*/
addEvent(functionName: string, time: number, parameter: Object): void;

/**
* Adds an animation event to the clip.
* @param event - The animation event
*/
addEvent(event: AnimationEvent): void {
this._events.push(event);
addEvent(event: AnimationEvent): void;


addEvent(param: AnimationEvent | string, time?: number, parameter?: Object): void {
if (typeof param === 'string') {
const event = new AnimationEvent();
event.functionName = param;
event.time = time;
event.parameter = parameter;
this._events.push(event);
} else {
this._events.push(param);
}
this._events.sort((a, b) => a.time - b.time);
}

Expand Down
36 changes: 27 additions & 9 deletions packages/core/src/animation/Animator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ export class Animator extends Component {
}
}

/**
* Get the playing state from the target layerIndex.
* @param layerIndex - The layer index
*/
getCurrentAnimatorState(layerIndex: number) {
return this._animatorLayersData[layerIndex]?.srcPlayData?.state;
}

/**
* @override
* @internal
Expand Down Expand Up @@ -490,9 +498,15 @@ export class Animator extends Component {

let crossWeight = destPlayData.frameTime / (destState._getDuration() * layerData.crossFadeTransition.duration);
crossWeight >= 1.0 && (crossWeight = 1.0);

srcPlayData.update();
destPlayData.update();

const { playState: srcPlayState } = srcPlayData;
const { playState: destPlayState } = destPlayData;

this._updateCrossFadeData(layerData, crossWeight, delta, false);

const { clipTime: srcClipTime } = srcPlayData;
const { clipTime: destClipTime } = destPlayData;

Expand All @@ -503,7 +517,7 @@ export class Animator extends Component {
if (lastSrcPlayState === AnimatorStatePlayState.UnStarted) {
this._callAnimatorScriptOnEnter(srcState, layerIndex);
}
if (crossWeight === 1 || srcPlayData.playState === AnimatorStatePlayState.Finished) {
if (crossWeight === 1 || srcPlayState === AnimatorStatePlayState.Finished) {
this._callAnimatorScriptOnExit(srcState, layerIndex);
} else {
this._callAnimatorScriptOnUpdate(srcState, layerIndex);
Expand All @@ -512,7 +526,7 @@ export class Animator extends Component {
if (lastDstPlayState === AnimatorStatePlayState.UnStarted) {
this._callAnimatorScriptOnEnter(destState, layerIndex);
}
if (destPlayData.playState === AnimatorStatePlayState.Finished) {
if (destPlayState === AnimatorStatePlayState.Finished) {
this._callAnimatorScriptOnExit(destState, layerIndex);
} else {
this._callAnimatorScriptOnUpdate(destState, layerIndex);
Expand All @@ -533,7 +547,6 @@ export class Animator extends Component {

this._applyCrossClipValue(curveOwner, srcValue, destValue, crossWeight, weight, additive);
}
this._updateCrossFadeData(layerData, crossWeight, delta, false);
}

private _updateCrossFadeFromPose(
Expand All @@ -552,16 +565,21 @@ export class Animator extends Component {

let crossWeight = destPlayData.frameTime / (state._getDuration() * layerData.crossFadeTransition.duration);
crossWeight >= 1.0 && (crossWeight = 1.0);

destPlayData.update();

const { playState } = destPlayData;

this._updateCrossFadeData(layerData, crossWeight, delta, true);

const { clipTime: destClipTime } = destPlayData;

eventHandlers.length && this._fireAnimationEvents(destPlayData, eventHandlers, lastDestClipTime, destClipTime);

if (lastPlayState === AnimatorStatePlayState.UnStarted) {
this._callAnimatorScriptOnEnter(state, layerIndex);
}
if (destPlayData.playState === AnimatorStatePlayState.Finished) {
if (playState === AnimatorStatePlayState.Finished) {
this._callAnimatorScriptOnExit(state, layerIndex);
} else {
this._callAnimatorScriptOnUpdate(state, layerIndex);
Expand All @@ -576,8 +594,6 @@ export class Animator extends Component {

this._applyCrossClipValue(curveOwner, curveOwner.fixedPoseValue, destValue, crossWeight, weight, additive);
}

this._updateCrossFadeData(layerData, crossWeight, delta, true);
}

private _updateCrossFadeData(layerData: AnimatorLayerData, crossWeight: number, delta: number, fixed: boolean): void {
Expand Down Expand Up @@ -793,11 +809,13 @@ export class Animator extends Component {
lastClipTime: number,
clipTime: number
): void {
const { state } = playState;
const clipDuration = state.clip.length;
// TODO: If play backward, not work.
if (clipTime < lastClipTime) {
this._fireSubAnimationEvents(playState, eventHandlers, lastClipTime, playState.state.clipEndTime);
this._fireSubAnimationEvents(playState, eventHandlers, lastClipTime, state.clipEndTime * clipDuration);
playState.currentEventIndex = 0;
this._fireSubAnimationEvents(playState, eventHandlers, playState.state.clipStartTime, clipTime);
this._fireSubAnimationEvents(playState, eventHandlers, state.clipStartTime * clipDuration, clipTime);
} else {
this._fireSubAnimationEvents(playState, eventHandlers, lastClipTime, clipTime);
}
Expand Down
18 changes: 9 additions & 9 deletions packages/core/src/animation/AnimatorState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class AnimatorState {
_onStateExitScripts: StateMachineScript[] = [];

private _clipStartTime: number = 0;
private _clipEndTime: number = Infinity;
private _clipEndTime: number = 1;
private _clip: AnimationClip;
private _transitions: AnimatorStateTransition[] = [];

Expand All @@ -44,28 +44,25 @@ export class AnimatorState {
}

/**
* The clip start time the user set , default is 0.
* The start time of the clip, the range is 0 to 1, default is 0.
*/
get clipStartTime() {
return this._clipStartTime;
}

set clipStartTime(time: number) {
this._clipStartTime = time < 0 ? 0 : time;
this._clipStartTime = Math.max(time, 0);
}

/**
* The clip end time the user set , default is the clip duration.
* The start time of the clip, the range is 0 to 1, default is 1.
*/
get clipEndTime() {
return this._clipEndTime;
}

set clipEndTime(time: number) {
const clip = this._clip;
if (clip) {
this._clipEndTime = Math.min(time, clip.length);
}
this._clipEndTime = Math.min(time, 1);
}

/**
Expand Down Expand Up @@ -123,7 +120,10 @@ export class AnimatorState {
* @internal
*/
_getDuration(): number {
return this._clipEndTime - this._clipStartTime;
if (this.clip) {
return (this._clipEndTime - this._clipStartTime) * this.clip.length;
}
return null;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/animation/internal/AnimatorStatePlayData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ export class AnimatorStatePlayData {
this.frameTime = offsetFrameTime;
this.stateData = stateData;
this.playState = AnimatorStatePlayState.UnStarted;
this.clipTime = this.state.clipStartTime;
this.clipTime = state.clipStartTime * state.clip.length;
this.currentEventIndex = 0;
}

update(): void {
const state = this.state;
let time = this.frameTime;
const duration = state.clipEndTime - state.clipStartTime;
const duration = state._getDuration();
this.playState = AnimatorStatePlayState.Playing;
if (time > duration) {
if (state.wrapMode === WrapMode.Loop) {
Expand All @@ -36,6 +36,6 @@ export class AnimatorStatePlayData {
this.playState = AnimatorStatePlayState.Finished;
}
}
this.clipTime = time + this.state.clipStartTime;
this.clipTime = time + state.clipStartTime * state.clip.length;
}
}
4 changes: 2 additions & 2 deletions packages/core/src/input/pointer/PointerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export class PointerManager {
htmlCanvas.onpointerdown = htmlCanvas.onpointerup = htmlCanvas.onpointerout = htmlCanvas.onpointermove = (evt:PointerEvent)=>{
this._nativeEvents.push(evt);
};
// MaxTouchCount + MouseCount(1)
this._pointerPool = new Array<Pointer>(navigator.maxTouchPoints + 1);
// If there are no compatibility issues, navigator.maxTouchPoints should be used here.
this._pointerPool = new Array<Pointer>(11);
this._enablePhysics = engine.physicsManager ? true : false;
}

Expand Down
Loading