Skip to content

Commit 944d426

Browse files
author
Maksims Mihejevs
committed
Merge branch 'master' of github.com:playcanvas/engine
2 parents 7db8773 + 578d13d commit 944d426

13 files changed

Lines changed: 130 additions & 21 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.176.1-dev
1+
0.177.0-dev

src/anim/anim_skeleton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pc.extend(pc, function () {
105105
// For each animated node...
106106

107107
// keys index offset
108-
var offset = (delta > 0 ? 1 : -1);
108+
var offset = (delta >= 0 ? 1 : -1);
109109

110110
for (i = 0; i < nodes.length; i++) {
111111
node = nodes[i];

src/asset/asset_asset.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ pc.extend(pc, function () {
220220
ASSET_MATERIAL: 'material',
221221
ASSET_TEXT: 'text',
222222
ASSET_TEXTURE: 'texture',
223-
ASSET_CUBEMAP: 'cubemap'
223+
ASSET_CUBEMAP: 'cubemap',
224+
ASSET_SHADER: 'shader',
225+
ASSET_CSS: 'css',
226+
ASSET_HTML: 'html'
224227
};
225228
}());

src/audio/audio_sound.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@ pc.extend(pc, function () {
33

44
var Sound;
55

6+
// checks if user is running IE
7+
var ie = function () {
8+
var ua = window.navigator.userAgent;
9+
10+
var msie = ua.indexOf('MSIE ');
11+
if (msie > 0) {
12+
// IE 10 or older => return version number
13+
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
14+
}
15+
16+
var trident = ua.indexOf('Trident/');
17+
if (trident > 0) {
18+
// IE 11 => return version number
19+
var rv = ua.indexOf('rv:');
20+
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
21+
}
22+
23+
return false;
24+
};
25+
626
if (pc.AudioManager.hasAudioContext()) {
727
Sound = function (manager, url, success, error) {
828
this.buffer = null;
@@ -46,14 +66,27 @@ pc.extend(pc, function () {
4666
console.warn(pc.string.format('Audio format for {0} not supported', url));
4767
success(this);
4868
} else {
69+
var isIE = ie();
70+
// audio needs to be added to the DOM for IE
71+
if (isIE)
72+
document.body.appendChild(this.audio);
73+
4974
this.audio.oncanplaythrough = function () {
75+
// remove from DOM no longer necessary
76+
if (isIE)
77+
document.body.removeChild(this.audio);
78+
5079
if (!this.isLoaded) {
5180
this.isLoaded = true;
5281
success(this);
5382
}
5483
}.bind(this);
5584

5685
this.audio.onerror = function () {
86+
// remove from DOM no longer necessary
87+
if (isIE)
88+
document.body.removeChild(this.audio);
89+
5790
// continue loading through error
5891
success(this);
5992
};

src/framework/components/animation/animation_component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pc.extend(pc, function () {
5151
data.currAnim = name;
5252

5353
if (data.model) {
54-
data.blending = blendTime > 0;
54+
data.blending = blendTime > 0 && data.prevAnim;
5555
if (data.blending) {
5656
// Blend from the current time of the current animation to the start of
5757
// the newly specified animation over the specified blend time period.

src/framework/components/audiosource/audiosource_component.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ pc.extend(pc, function () {
245245
},
246246

247247
loadAudioSourceAssets: function (ids) {
248+
var self = this;
249+
248250
var assets = ids.map(function (id) {
249251
return this.system.app.assets.get(id);
250252
}, this);
@@ -290,6 +292,9 @@ pc.extend(pc, function () {
290292
_done();
291293
}
292294
});
295+
296+
if (! asset.resource)
297+
this.system.app.assets.load(asset);
293298
} else {
294299
// don't wait for assets that aren't in the registry
295300
count--;
@@ -299,8 +304,11 @@ pc.extend(pc, function () {
299304
// but if they are added insert them into source list
300305
this.system.app.assets.on("add:" + ids[index], function (asset) {
301306
asset.ready(function (asset) {
302-
this.data.sources[asset.name] = asset.resource;
307+
self.data.sources[asset.name] = asset.resource;
303308
});
309+
310+
if (! asset.resource)
311+
self.system.app.assets.load(asset);
304312
});
305313
}
306314
}, this);

src/graphics/graphics_device.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ pc.extend(pc, function () {
916916
gl.generateMipmap(texture._glTarget);
917917
}
918918

919+
if (texture._gpuSize) this._vram.tex -= texture._gpuSize;
919920
texture._gpuSize = gpuTexSize(gl, texture);
920921
this._vram.tex += texture._gpuSize;
921922
},
@@ -1061,7 +1062,7 @@ pc.extend(pc, function () {
10611062
}
10621063

10631064
// Commit the shader program variables
1064-
textureUnit = 0;
1065+
var textureUnit = 0;
10651066
for (i = 0, len = samplers.length; i < len; i++) {
10661067
sampler = samplers[i];
10671068
samplerValue = sampler.scopeId.value;
@@ -1238,7 +1239,7 @@ pc.extend(pc, function () {
12381239
* @description Sets the specified render target on the device. If null
12391240
* is passed as a parameter, the back buffer becomes the current target
12401241
* for all rendering operations.
1241-
* @param {pc.RenderTarget} The render target to activate.
1242+
* @param {pc.RenderTarget} renderTarget The render target to activate.
12421243
* @example
12431244
* // Set a render target to receive all rendering output
12441245
* device.setRenderTarget(renderTarget);

src/graphics/graphics_vertexformat.js

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,58 @@ pc.extend(pc, function () {
1212

1313
/**
1414
* @name pc.VertexFormat
15-
* @class A vertex format is a descriptor that defines the layout of vertex element data inside
16-
* a pc.VertexBuffer object.
17-
* @description Returns a new pc.VertexFormat object. It is constructed from a description
18-
* that explicitly defines how data is to be laid out inside a vertex buffer (pc.VertexBuffer).
19-
* The description is defined as an array of elements, where each element is an object with the
20-
* following properties:
21-
* semantic: pc.SEMANTIC_.
22-
* components: the number of components used by the element.
23-
* type: (pc.ELEMENTTYPE_).
24-
* normalize: true to remap element values to a range of 0 to 1. Defaults to false.
15+
* @class A vertex format is a descriptor that defines the layout of vertex data inside
16+
* a {@link pc.VertexBuffer}.
17+
* @description Returns a new pc.VertexFormat object.
2518
* @param {pc.GraphicsDevice} graphicsDevice The graphics device used to manage this vertex format.
26-
* @param {Object[]} description An array of vertex element descriptions.
19+
* @param {Object[]} description An array of vertex attribute descriptions.
20+
* @param {Number} description[].semantic The meaning of the vertex element. This is used to link
21+
* the vertex data to a shader input. Can be:
22+
* <ul>
23+
* <li>pc.SEMANTIC_POSITION</li>
24+
* <li>pc.SEMANTIC_NORMAL</li>
25+
* <li>pc.SEMANTIC_TANGENT</li>
26+
* <li>pc.SEMANTIC_BLENDWEIGHT</li>
27+
* <li>pc.SEMANTIC_BLENDINDICES</li>
28+
* <li>pc.SEMANTIC_COLOR</li>
29+
* <li>pc.SEMANTIC_TEXCOORD0</li>
30+
* <li>pc.SEMANTIC_TEXCOORD1</li>
31+
* <li>pc.SEMANTIC_TEXCOORD2</li>
32+
* <li>pc.SEMANTIC_TEXCOORD3</li>
33+
* <li>pc.SEMANTIC_TEXCOORD4</li>
34+
* <li>pc.SEMANTIC_TEXCOORD5</li>
35+
* <li>pc.SEMANTIC_TEXCOORD6</li>
36+
* <li>pc.SEMANTIC_TEXCOORD7</li>
37+
* </ul>
38+
* If vertex data has a meaning other that one of those listed above, use the user-defined
39+
* semantics: pc.SEMANTIC_ATTR0 to pc.SEMANTIC_ATTR15.
40+
* @param {Number} description[].components The number of components of the vertex attribute.
41+
* Can be 1, 2, 3 or 4.
42+
* @param {Number} description[].type The data type of the attribute. Can be:
43+
* <ul>
44+
* <li>pc.ELEMENTTYPE_INT8</li>
45+
* <li>pc.ELEMENTTYPE_UINT8</li>
46+
* <li>pc.ELEMENTTYPE_INT16</li>
47+
* <li>pc.ELEMENTTYPE_UINT16</li>
48+
* <li>pc.ELEMENTTYPE_INT32</li>
49+
* <li>pc.ELEMENTTYPE_UINT32</li>
50+
* <li>pc.ELEMENTTYPE_FLOAT32</li>
51+
* </ul>
52+
* @param {Boolean} description[].normalize If true, vertex attribute data will be mapped from a
53+
* 0 to 255 range down to 0 to 1 when fed to a shader. If false, vertex attribute data is left
54+
* unchanged. If this property is unspecified, false is assumed.
2755
* @example
56+
* // Specify 3-component positions (x, y, z)
57+
* var vertexFormat = new pc.VertexFormat(graphicsDevice, [
58+
* { semantic: pc.SEMANTIC_POSITION, components: 3, type: pc.ELEMENTTYPE_FLOAT32 },
59+
* ]);
60+
* @example
61+
* // Specify 2-component positions (x, y), a texture coordinate (u, v) and a vertex color (r, g, b, a)
2862
* var vertexFormat = new pc.VertexFormat(graphicsDevice, [
2963
* { semantic: pc.SEMANTIC_POSITION, components: 2, type: pc.ELEMENTTYPE_FLOAT32 },
3064
* { semantic: pc.SEMANTIC_TEXCOORD0, components: 2, type: pc.ELEMENTTYPE_FLOAT32 },
3165
* { semantic: pc.SEMANTIC_COLOR, components: 4, type: pc.ELEMENTTYPE_UINT8, normalize: true }
3266
* ]);
33-
*
3467
* @author Will Eastcott
3568
*/
3669
var VertexFormat = function (graphicsDevice, description) {

src/input/input_mouse.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,13 @@ pc.extend(pc, function () {
218218
* @param {Function} [error] Function called if the request for mouse lock is unsuccessful.
219219
*/
220220
enablePointerLock: function (success, error) {
221+
if (! document.body.requestPointerLock) {
222+
if (error)
223+
error();
224+
225+
return;
226+
}
227+
221228
var s = function () {
222229
success();
223230
document.removeEventListener('pointerlockchange', s);
@@ -245,6 +252,10 @@ pc.extend(pc, function () {
245252
* @param {Function} [success] Function called when the mouse lock is disabled
246253
*/
247254
disablePointerLock: function (success) {
255+
if (! document.exitPointerLock) {
256+
return;
257+
}
258+
248259
var s = function () {
249260
success();
250261
document.removeEventListener('pointerlockchange', s);

src/resources/parser_jsonmodel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ pc.extend(pc, function () {
170170
indices = indices.concat(modelData.meshes[j].indices);
171171
}
172172
}
173-
tangents = pc.calculateTangents(vertexData.position.data, vertexData.normal.data, vertexData.texCoord0.data, indices);
173+
var tangents = pc.calculateTangents(vertexData.position.data, vertexData.normal.data, vertexData.texCoord0.data, indices);
174174
vertexData.tangent = { type: "float32", components: 4, data: tangents };
175175
}
176176

0 commit comments

Comments
 (0)