Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
0516568
Create the anim component
Mar 26, 2020
8791178
Unified the glb and anim clip paths in the binder
Apr 21, 2020
1331455
cleanup anim controller state transition code
Apr 21, 2020
5705a4b
anim controller cleanup
Apr 21, 2020
21ae4b5
support multiple animations in a single AnimState
Apr 21, 2020
fcaa9c0
spelling fix
Apr 22, 2020
b97f8ad
make the anim controller parameter driven and introduce transition ex…
Apr 24, 2020
46cc873
add transition offsets which allow for the entry time of destination …
Apr 24, 2020
76280c7
add a reset function to the anim controller and expose it in the anim…
Apr 24, 2020
bfb66d9
update anim clips after transitions and blending
Apr 24, 2020
314ee11
Update anim clip names to include state name
Apr 27, 2020
7d00286
syntax update
Apr 27, 2020
8a26728
use enums throughout the anim controller
Apr 27, 2020
c68bde5
Add transition interruption sources to the anim controller
Apr 27, 2020
17cd652
enclose logging in DEBUG conditionals
Apr 28, 2020
56e3d0d
Switch object copying to use object assign
Apr 28, 2020
86cad69
expose anim enums in the pc namespace
Apr 28, 2020
7b245f7
Update the anim property locator to escape forward slashes and cleanu…
Apr 28, 2020
6f5e31a
cache transitions when searching from and between states
Apr 28, 2020
f10f6c1
update anim controller parameters get/set methods
Apr 28, 2020
9d834cc
add jsdocs
Apr 29, 2020
2433108
anim component system cleanup
Apr 29, 2020
92f8e5b
anim component adjustments
Apr 29, 2020
726b98b
update anim component properties
Apr 30, 2020
d3cf7ca
remove unused code
Apr 30, 2020
94cabe9
remove functions to get active state name and progress
Apr 30, 2020
a5b8bfd
Merge branch 'master' into anim-component
May 1, 2020
2f8545c
update anim component to support morph targets
May 1, 2020
7f256a3
fix anim test
May 1, 2020
4257e1c
fix jsdocs
May 1, 2020
d0543a1
lint fix
May 1, 2020
a59c839
add a pause function & update enum types
May 5, 2020
ca75945
Update to anim component and controller code style
May 6, 2020
7247876
styling updates
May 6, 2020
0c9e3c4
fix breaking changes
May 6, 2020
89566a8
update typechecking
May 6, 2020
a69d95d
Merge branch 'master' into anim-component
May 6, 2020
3264612
code style changes
May 7, 2020
5304e54
animation clips can store multi component keyframe outputs
May 11, 2020
d94c1a3
Add an animatable properties engine example
May 11, 2020
a056978
update the animatable properties example
May 11, 2020
bf73691
update the anim component api
May 11, 2020
2016252
jsdocs fix
May 11, 2020
278f2c9
correctly handle transition iterruptions which return the controller …
May 12, 2020
e06b939
add a character animation example
May 12, 2020
1aa8828
record the previous transition states index in its name to uniquely i…
May 13, 2020
e55b9d4
performance update and comments for the anim controller
May 13, 2020
1afbd4a
add anim component layers to the anim component
May 18, 2020
ce25474
update examples
May 18, 2020
8898c79
jsdocs fix
May 18, 2020
ada6279
jsdocs fix
May 18, 2020
7883826
state graph multiple layers fix
May 18, 2020
655f08d
wip: test returning entity instead of model from parser
May 22, 2020
1476e77
feat(GlbParser): return pc.Entity instead of pc.Model as scene
May 25, 2020
5d6c787
refactor(GlbParser): remove now unused createModel method
May 25, 2020
3803bbd
feat(GlbParser): add support for glTF properties scene and scenes
May 25, 2020
df12ec6
refactor(GlbParser): remove unused code
May 25, 2020
e5f2cc2
fix(GlbParser): fix animation curve paths by using node names in pc.M…
May 25, 2020
36192ab
refactor(GlbParser): remove "model_" prefix from pc.Model root nodes
May 26, 2020
b387449
wip(GlbParser): automatically add animation components to entities in…
May 26, 2020
9a8e40d
fix: allow animation of entities without model components, e.g. group…
May 26, 2020
d82ebc8
fix(pc.Model): keep references to bone nodes outside the model when c…
May 27, 2020
8d98403
refactor(GlbParser): handle absence of scene node with null instead o…
May 28, 2020
69372f4
refactor(GlbParser): remove animationComponents from container data
May 28, 2020
288e2ef
fix(GlbParser): fix cleanup process for ContainerResource
May 28, 2020
3b3faad
refactor(ContainerResource): use Array.map instead of for loop to cre…
May 28, 2020
bdee645
refactor(GlbParser): propagate default material from ContainerHandler…
May 28, 2020
b039aff
chore(GlbParser): remove todo comment
May 28, 2020
bd5eb3f
fix(AnimationComponent): make it possible to use AnimationComponent o…
May 28, 2020
4a87dd5
chore(ContainerResource): update jsdoc documentation
May 28, 2020
3540283
addressed PR comments
May 28, 2020
855d05c
Merge remote-tracking branch 'ellt92/anim-component' into feature/new…
May 29, 2020
e976903
feat(GlbParser): use new pc.AnimComponent
May 29, 2020
9835700
refactor(GlbParser): refactor the way node locator paths are calculat…
May 29, 2020
a975095
fix(AnimComponentSystem): remove call to undefined function
May 29, 2020
ae76a07
refactor(ContainerResource): remove console.log
May 29, 2020
85de1af
refactor(GlbParser): add sanity check for nodeComponents in createMod…
May 29, 2020
5822254
fix(ContainerResource): make sure anim components are enabled by defa…
May 29, 2020
98e1318
chore(AnimComponent): fix jsdoc/typings
May 29, 2020
72c8a68
Merge branch 'master' into feature/gltf-scene-support
Jun 1, 2020
9b60ba2
1.28.0-rc.0
Jun 1, 2020
2e6ad0b
create a new animation update step in the component system, expose la…
Jun 1, 2020
44889fb
Merge branch 'master' into anim-component
Jun 1, 2020
14aae18
Merge remote-tracking branch 'ellt92/anim-component' into feature/glt…
Jun 1, 2020
456d9a8
fix(AnimComponent): make methods and properties public
Jun 1, 2020
da3dfaf
refactor(ContainerResource): use prop pc.AnimComponentLayer.states to…
Jun 1, 2020
4bdc4e5
anim component play state fix
Jun 2, 2020
23d7422
Merge branch 'master' into anim-component
Jun 2, 2020
8cddf52
PR comments
Jun 2, 2020
855ba30
test fix
Jun 2, 2020
3d16a3a
find enities using the findByPath function in the anim binder
Jun 2, 2020
becf669
handle null case for anim findAnimationLayer
Jun 2, 2020
5e832d5
updated the assignAnimation function
Jun 2, 2020
915b70d
pro comments
Jun 3, 2020
adcf1da
update anim resource names
Jun 3, 2020
451dcb9
flag animation udpates to any materials
Jun 4, 2020
ec5b99c
fix the anim controllers playable variable
Jun 4, 2020
e879b73
add a new baseLayer variable to the anim component and fix the stateG…
Jun 4, 2020
20f50e9
Merge branch 'master' into anim-component
Jun 4, 2020
60cd93c
fix merge issue
Jun 4, 2020
99f9c8b
change how the anim binder flags materials
Jun 5, 2020
62c396a
Merge branch 'master' into anim-component
Jun 5, 2020
0b35179
anim controller syntax change
Jun 5, 2020
69b6d5c
Merge remote-tracking branch 'upstream/anim-component' into feature/g…
Jun 5, 2020
0c19f10
fix(ContainerHandler): fix issue with baseUrl introduced in merge
Jun 5, 2020
13b5340
fix(GlbParser): prevent double asset prefixes in texture urls
Jun 5, 2020
506f436
fix(ContainerHandler): fix scenes unloading
Jun 5, 2020
0e668e9
Merge branch 'master' into feature/gltf-scene-support
Jun 5, 2020
c5c8524
fix(GlbParser): fix so that slashes in node names don't interfere wit…
Jun 5, 2020
3a96424
ci: fix ci error
Jun 5, 2020
eac2d56
fix: fix lint errors
Jun 5, 2020
904dec0
Merge branch 'master' into feature/gltf-scene-support
Jun 8, 2020
ccca2ec
refactor(GlbParser): change argument order of parseAsync
Jun 8, 2020
ae8475d
Merge remote-tracking branch 'upstream/master' into feature/gltf-scen…
Jun 12, 2020
3282a02
Merge branch 'master' into feature/gltf-scene-support
Jun 12, 2020
d0a8988
fix: make AnimTrack public
Jun 17, 2020
d1678ca
fix: typings for AnimTrack.name and AnimComponentLayer.playing
Jun 18, 2020
deaf615
fix: add implementation for AnimController.playing
Jun 18, 2020
32ef6fd
feat(AnimComponent): make it possible to not loop animations by provi…
Jun 18, 2020
1105243
feat(GlbParser): make it possible to not loop animations (WIP)
Jun 18, 2020
4a08137
feat: make AnimComponent methods and props public
Jun 23, 2020
86e8d40
feat(ContainerResource): return node-animation mapping instead of ass…
Jun 23, 2020
9340980
refactor(GlbParser): remove unnecessary graph node per mesh instance …
Jun 23, 2020
88d2791
feat(ContainerResource): return animation index instead of asset in n…
Jun 24, 2020
41fb0bd
chore: revert AnimComponent jsdoc
Jun 25, 2020
a335f72
Merge branch 'master' into feature/gltf-scene-support
Jun 26, 2020
f238026
feat: re-apply changes to container resource that were lost in upstre…
Jun 26, 2020
bae3188
feat: re-apply changes to GLB parser that were lost in upstream merge
Jun 26, 2020
57e6f96
1.30.0-rc.0
Jun 26, 2020
558ecf5
fix(GlbParser): fix broken reference to Entity
Jun 26, 2020
6d9e978
Revert "1.30.0-rc.0"
Jun 29, 2020
1bd4781
feat(GlbParser): return model per glTF mesh as well as model per node
Jul 2, 2020
7b47425
refactor(ContainerResource): add _ prefix to nodeModels to signal tha…
Jul 2, 2020
b9e35c2
refactor(GlbParser): clone node models instead of running createModel…
Jul 2, 2020
2a18395
fix(GlbParser): fix typo
Jul 2, 2020
9330c09
feat(ContainerResource): include nodes in result since it may be rele…
Jul 2, 2020
d4a0e5a
chore(ContainerResource): add note about _nodeModels
Jul 21, 2020
c0fddb2
feat(GlbParser): add support for glTF cameras
Jul 22, 2020
2275965
feat(GlbParser): add support for KHR_lights_punctual
Jul 23, 2020
c407939
Merge branch 'master' into feature/gltf-scene-support
Jul 24, 2020
de9a563
feat(GlbParser): optimize reusing skin instances as implemented in ht…
Jul 24, 2020
546d138
refactor(GlbParser): simplify creation of nodeModels by removing need…
Jul 24, 2020
59510bb
refactor(GlbParser): replace nodeComponents with nodeAnimations
Jul 24, 2020
a23b3be
chore(ContainerResource): remove unnecessary comments
Jul 24, 2020
1c70dbf
feat(ContainerResource): include both images and textures in container
Jul 24, 2020
b057e3a
chore(ContainerResource): update jsdoc
Jul 24, 2020
a2bcd8b
Merge branch 'master' into feature/gltf-scene-support
Jul 24, 2020
4820136
Merge branch 'master' into feature/gltf-scene-support
Jul 28, 2020
54b0fdc
Merge branch 'master' into feature/gltf-scene-support
Jul 28, 2020
c944b67
refactor(AnimState): remove duplicate property "loop"
Jul 28, 2020
0e6f465
Merge branch 'master' into feature/gltf-scene-support
Jul 30, 2020
eb853e4
fix(GlbParser): fix incorrect reference to camera callbacks
Jul 30, 2020
f5ae9b2
refactor(GlbParser): use Number.POSITIVE_INFINITY for infinite light …
Aug 21, 2020
7a29662
refactor(GlbParser): remove use of Object.assign for camera props
Aug 21, 2020
a792880
refactor(GlbParser): rename variable
Aug 24, 2020
29a8d99
feat(GlbParser): add support for light extensions
Aug 24, 2020
ecccb5f
refactor(ContainerResource): rename nodeAnimations to animationIndice…
Aug 25, 2020
4505a72
refactor(GlbParser): handle null AssetRegistry prefix when loading te…
Aug 25, 2020
9f90919
Merge branch 'master' into feature/gltf-scene-support
Aug 25, 2020
ddf1069
fix(ContainerResource): fix merge issue
Aug 25, 2020
4a513b8
fix(GlbParser): fix typo causing bugs with options.texture.postprocess
Aug 25, 2020
cd76697
refactor(GlbParser): replace use of const with var
Aug 25, 2020
1a81d8f
refactor(GlbParser): remove use of array spread syntax
Aug 25, 2020
334318b
refactor(GlbParser): replace use of const with var
Aug 25, 2020
71d8e56
Merge branch 'master' into feature/gltf-scene-support
Aug 26, 2020
455f9eb
fix(ContainerHandler): add missing null check for container
Aug 26, 2020
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
138 changes: 111 additions & 27 deletions src/resources/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,35 @@ import { GlbParser } from './parser/glb-parser.js';
/**
* @class
* @name pc.ContainerResource
* @classdesc Container for a list of animations, textures, materials and a model.
* @classdesc Container for a list of animations, textures, materials, models, nodes, scenes, default scene
* cameras and lights. Entities in scene hierarchies will have model, camera and light components attached to them.
* Animation components have to be added manually (using animationIndicesByNode) as either pc.AnimComponent or pc.AnimationComponent.
* @param {object} data - The loaded GLB data.
* @property {pc.Entity|null} scene Root entity of the default GLB scene.
* @property {pc.Entity[]} scenes Root entities of scenes indexed by GLB scenes.
* @property {pc.CameraComponent[]} cameras Instanced camera components, does not match index of GLB cameras.
* @property {pc.LightComponent[]} lights Instanced light components, does not match index of GLB lights.
* @property {pc.Entity[]} nodes Entities indexed by GLB nodes.
* @property {pc.Asset[]} materials Material assets indexed by GLB materials.
* @property {pc.Asset[]} textures Texture assets indexed by GLB textures.
* @property {pc.Asset[]} animations Animation assets indexed by GLB animations.
* @property {number[][]} animationIndicesByNode Animation asset indices indexed by GLB nodes.
* @property {pc.Asset[]} models Model assets indexed by GLB meshes.
* @property {pc.AssetRegistry} registry The asset registry.
*/
function ContainerResource(data) {
this.data = data;
this.model = null;
this.scene = null;
this.scenes = [];
this.cameras = [];
this.lights = [];
this.nodes = [];
this.materials = [];
this.textures = [];
this.animations = [];
this.animationIndicesByNode = [];
this.models = [];
this._modelByNode = []; // not public since it is only used to keep model refs for when container is destroyed
this.registry = null;
}

Expand All @@ -33,16 +53,60 @@ Object.assign(ContainerResource.prototype, {

var destroyAssets = function (assets) {
assets.forEach(function (asset) {
destroyAsset(asset);
if (asset) {
destroyAsset(asset);
}
});
};

// destroy entities
if (this.scene) {
this.scene.destroy();
this.scene = null;
}

if (this.scenes) {
this.scenes.forEach(function (scene) {
scene.destroy();
});
this.scenes = null;
}

if (this.cameras) {
this.cameras = null;
}

if (this.lights) {
this.lights = null;
}

if (this.nodes) {
this.nodes.forEach(function (node) {
node.destroy();
});
this.nodes = null;
}

// unload and destroy assets
if (this.animations) {
destroyAssets(this.animations);
this.animations = null;
}

if (this.animationIndicesByNode) {
this.animationIndicesByNode = null;
}

if (this.models) {
destroyAssets(this.models);
this.models = null;
}

if (this._modelByNode) {
destroyAssets(this._modelByNode);
this._modelByNode = null;
}

if (this.textures) {
destroyAssets(this.textures);
this.textures = null;
Expand All @@ -53,11 +117,6 @@ Object.assign(ContainerResource.prototype, {
this.materials = null;
}

if (this.model) {
destroyAsset(this.model);
this.model = null;
}

this.data = null;
this.assets = null;
}
Expand All @@ -68,7 +127,7 @@ Object.assign(ContainerResource.prototype, {
* @name pc.ContainerHandler
* @implements {pc.ResourceHandler}
* @classdesc Loads files that contain multiple resources. For example glTF files can contain
* textures, models and animations.
* textures, scenes and animations.
* The asset options object can be used to pass load time callbacks for handling the various resources
* at different stages of loading. The table below lists the resource types and the corresponding
* supported process functions.
Expand All @@ -78,6 +137,9 @@ Object.assign(ContainerResource.prototype, {
* |-------------+-------------+-------------+-------------+-------------|
* | global | x | | | x |
* | node | x | x | | x |
* | scene | x | x | | x |
* | camera | x | x | | x |
* | light | x | x | | x |
* | animation | x | | | x |
* | material | x | x | | x |
* | image | x | | x | x |
Expand Down Expand Up @@ -128,6 +190,7 @@ Object.assign(ContainerHandler.prototype, {
path.extractPath(url.load),
arrayBuffer,
self._device,
self._defaultMaterial,
asset.registry,
asset.options,
function (err, result) {
Expand Down Expand Up @@ -162,7 +225,7 @@ Object.assign(ContainerHandler.prototype, {
return data;
},

// Create assets to wrap the loaded engine resources - model, materials, textures and animations.
// Create assets to wrap the loaded engine resources - models, materials, textures and animations.
patch: function (asset, assets) {
var container = asset.resource;
var data = container && container.data;
Expand All @@ -178,28 +241,49 @@ Object.assign(ContainerHandler.prototype, {
return subAsset;
};

var i;
// create model assets
var modelAssets = data.models.map(function (model, index) {
return createAsset('model', model, index);
});

// create model asset
var model = createAsset('model', GlbParser.createModel(data, this._defaultMaterial), 0);
// create node model assets
var modelAssetByNode = data.modelByNode.map(function (model, index) {
return model !== null ? createAsset('model', model, index) : null;
});

// create material assets
var materials = [];
for (i = 0; i < data.materials.length; ++i) {
materials.push(createAsset('material', data.materials[i], i));
}
var materialAssets = data.materials.map(function (material, index) {
return createAsset('material', material, index);
});

// create animation assets
var animations = [];
for (i = 0; i < data.animations.length; ++i) {
animations.push(createAsset('animation', data.animations[i], i));
}

container.data = null; // since assets are created, release GLB data
container.model = model;
container.materials = materials;
container.textures = data.textures; // texture assets are created directly
container.animations = animations;
var animationAssets = data.animations.map(function (animation, index) {
return createAsset('animation', animation, index);
});

// add model components to nodes
data.nodes.forEach(function (node, nodeIndex) {
var modelAsset = modelAssetByNode[nodeIndex];
if (modelAsset !== null) {
node.addComponent('model', {
type: 'asset',
asset: modelAsset
});
}
});

container.data = null; // since assets are created, release GLB data
container.scene = data.scene;
container.scenes = data.scenes;
container.cameras = data.cameras;
container.lights = data.lights;
container.nodes = data.nodes;
container.materials = materialAssets;
container.textures = data.textures; // texture assets are created in parser
container.animations = animationAssets;
container.animationIndicesByNode = data.animationIndicesByNode;
container.models = modelAssets;
container._modelByNode = modelAssetByNode; // keep model refs for when container is destroyed
container.registry = assets;
}
}
Expand Down
Loading