shader updates
parent
37d670022d
commit
d534f99f5e
|
@ -34,7 +34,7 @@ GameLib.Event.TEXTURE_ANIMATED_CHANGE = 0x10;
|
||||||
GameLib.Event.ANIMATE_TEXTURE_INSTANCE = 0x11;
|
GameLib.Event.ANIMATE_TEXTURE_INSTANCE = 0x11;
|
||||||
GameLib.Event.REMOVE_PARTICLE_ENGINE = 0x12;
|
GameLib.Event.REMOVE_PARTICLE_ENGINE = 0x12;
|
||||||
GameLib.Event.GAME_PAUSE = 0x13;
|
GameLib.Event.GAME_PAUSE = 0x13;
|
||||||
//GameLib.Event.TEXTURE_INSTANCE_UPDATED = 0x14;
|
GameLib.Event.SHADER_UPDATE = 0x14;
|
||||||
GameLib.Event.PLAY_AUDIO = 0x15;
|
GameLib.Event.PLAY_AUDIO = 0x15;
|
||||||
GameLib.Event.MATERIAL_INSTANCE_UPDATED = 0x16;
|
GameLib.Event.MATERIAL_INSTANCE_UPDATED = 0x16;
|
||||||
GameLib.Event.PAUSE_AUDIO = 0x17;
|
GameLib.Event.PAUSE_AUDIO = 0x17;
|
||||||
|
@ -161,7 +161,7 @@ GameLib.Event.GetEventName = function(number) {
|
||||||
case 0x11 : return 'animate_texture_instance';
|
case 0x11 : return 'animate_texture_instance';
|
||||||
case 0x12 : return 'remove_particle_engine';
|
case 0x12 : return 'remove_particle_engine';
|
||||||
case 0x13 : return 'pause';
|
case 0x13 : return 'pause';
|
||||||
case 0x14 : return 'texture_instance_updated';
|
case 0x14 : return 'shader_update';
|
||||||
case 0x15 : return 'play_audio';
|
case 0x15 : return 'play_audio';
|
||||||
case 0x16 : return 'material_instance_updated';
|
case 0x16 : return 'material_instance_updated';
|
||||||
case 0x17 : return 'pause_audio';
|
case 0x17 : return 'pause_audio';
|
||||||
|
|
|
@ -206,7 +206,7 @@ GameLib.Component.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
if (property === 'parentEntity') {
|
if (property === 'parentEntity') {
|
||||||
|
|
||||||
if (this.parentEntity && this.parentEntity.loaded) {
|
if (this.parentEntity instanceof GameLib.Entity) {
|
||||||
this.parentEntity.addComponent(this);
|
this.parentEntity.addComponent(this);
|
||||||
|
|
||||||
this.buildIdToObject();
|
this.buildIdToObject();
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
* @param path
|
* @param path
|
||||||
* @param contentType
|
* @param contentType
|
||||||
* @param size
|
* @param size
|
||||||
|
* @param width
|
||||||
|
* @param height
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.API.Image = function(
|
GameLib.API.Image = function(
|
||||||
|
|
|
@ -101,6 +101,31 @@ GameLib.CustomCode.prototype.launchEditor = function(){
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (this instanceof GameLib.D3.Shader.Vertex) {
|
||||||
|
this.editor = this.coder.instance(
|
||||||
|
document.body,
|
||||||
|
{
|
||||||
|
value: this.code,
|
||||||
|
mode: 'x-shader/x-vertex',
|
||||||
|
lineNumbers: true,
|
||||||
|
scrollbarStyle: 'overlay',
|
||||||
|
indentWithTabs: true,
|
||||||
|
indentUnit: 4
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else if (this instanceof GameLib.D3.Shader.Fragment) {
|
||||||
|
this.editor = this.coder.instance(
|
||||||
|
document.body,
|
||||||
|
{
|
||||||
|
value: this.code,
|
||||||
|
mode: 'x-shader/x-fragment',
|
||||||
|
lineNumbers: true,
|
||||||
|
scrollbarStyle: 'overlay',
|
||||||
|
indentWithTabs: true,
|
||||||
|
indentUnit: 4
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
this.editor = this.coder.instance(
|
this.editor = this.coder.instance(
|
||||||
document.body,
|
document.body,
|
||||||
{
|
{
|
||||||
|
@ -112,6 +137,9 @@ GameLib.CustomCode.prototype.launchEditor = function(){
|
||||||
indentUnit: 4
|
indentUnit: 4
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.editor.on('change', function(){
|
this.editor.on('change', function(){
|
||||||
|
|
||||||
|
|
|
@ -65,23 +65,3 @@ GameLib.D3.API.Fog = function(
|
||||||
|
|
||||||
GameLib.D3.API.Fog.prototype = Object.create(GameLib.API.Component.prototype);
|
GameLib.D3.API.Fog.prototype = Object.create(GameLib.API.Component.prototype);
|
||||||
GameLib.D3.API.Fog.prototype.constructor = GameLib.D3.API.Fog;
|
GameLib.D3.API.Fog.prototype.constructor = GameLib.D3.API.Fog;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an API scene from an Object scene
|
|
||||||
* @param objectFog
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.API.Fog.FromObject = function(objectFog) {
|
|
||||||
|
|
||||||
return new GameLib.D3.API.Fog(
|
|
||||||
objectFog.id,
|
|
||||||
objectFog.name,
|
|
||||||
objectFog.exponential,
|
|
||||||
objectFog.color,
|
|
||||||
objectFog.near,
|
|
||||||
objectFog.far,
|
|
||||||
objectFog.density,
|
|
||||||
objectFog.parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* @param name
|
* @param name
|
||||||
* @param shaderType
|
* @param shaderType
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
|
* @param parentMaterialShader
|
||||||
* @param code
|
* @param code
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -12,6 +13,7 @@ GameLib.D3.API.Shader = function(
|
||||||
name,
|
name,
|
||||||
shaderType,
|
shaderType,
|
||||||
parentEntity,
|
parentEntity,
|
||||||
|
parentMaterialShader,
|
||||||
code
|
code
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -46,8 +48,24 @@ GameLib.D3.API.Shader = function(
|
||||||
}
|
}
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(parentMaterialShader)) {
|
||||||
|
parentMaterialShader = null;
|
||||||
|
}
|
||||||
|
this.parentMaterialShader = parentMaterialShader;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(code)) {
|
if (GameLib.Utils.UndefinedOrNull(code)) {
|
||||||
|
switch (this.shaderType) {
|
||||||
|
case GameLib.D3.API.Shader.SHADER_TYPE_VERTEX:
|
||||||
|
code = "void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";
|
||||||
|
break;
|
||||||
|
case GameLib.D3.API.Shader.SHADER_TYPE_FRAGMENT:
|
||||||
|
code = "void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
console.warn('unhandled shader type to initialize code for:' + this.name);
|
||||||
code = '';
|
code = '';
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ GameLib.D3.API.Shader.Fragment = function(
|
||||||
apiShader.name,
|
apiShader.name,
|
||||||
apiShader.shaderType,
|
apiShader.shaderType,
|
||||||
apiShader.parentEntity,
|
apiShader.parentEntity,
|
||||||
|
apiShader.parentMaterialShader,
|
||||||
apiShader.code
|
apiShader.code
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,6 +23,7 @@ GameLib.D3.API.Shader.Vertex = function(
|
||||||
apiShader.name,
|
apiShader.name,
|
||||||
apiShader.shaderType,
|
apiShader.shaderType,
|
||||||
apiShader.parentEntity,
|
apiShader.parentEntity,
|
||||||
|
apiShader.parentMaterialShader,
|
||||||
apiShader.code
|
apiShader.code
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -132,22 +132,3 @@ GameLib.D3.Fog.prototype.toApiObject = function() {
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a scene Object to a GameLib.D3.Fog object
|
|
||||||
* @param graphics GameLib.GraphicsRuntime
|
|
||||||
* @param objectFog Object
|
|
||||||
* @returns {GameLib.D3.Fog}
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
GameLib.D3.Fog.FromObject = function(
|
|
||||||
graphics,
|
|
||||||
objectFog
|
|
||||||
) {
|
|
||||||
var apiFog = GameLib.D3.API.Fog.FromObject(objectFog);
|
|
||||||
|
|
||||||
return new GameLib.D3.Fog(
|
|
||||||
graphics,
|
|
||||||
apiFog
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ GameLib.D3.Material.Shader = function(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.API.Material.Shader.call(
|
GameLib.D3.API.Material.Shader.call(
|
||||||
this,
|
this,
|
||||||
apiMaterialShader,
|
apiMaterialShader,
|
||||||
|
@ -52,21 +51,37 @@ GameLib.D3.Material.Shader = function(
|
||||||
GameLib.D3.Material.Shader.prototype = Object.create(GameLib.D3.Material.prototype);
|
GameLib.D3.Material.Shader.prototype = Object.create(GameLib.D3.Material.prototype);
|
||||||
GameLib.D3.Material.Shader.prototype.constructor = GameLib.D3.Material.Shader;
|
GameLib.D3.Material.Shader.prototype.constructor = GameLib.D3.Material.Shader;
|
||||||
|
|
||||||
|
GameLib.D3.Material.Shader.prototype.commonInstance = function() {
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of our texture object
|
* Creates an instance of our texture object
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Material.Shader.prototype.createInstance = function() {
|
GameLib.D3.Material.Shader.prototype.createInstance = function() {
|
||||||
|
|
||||||
var fragmentShader = '';
|
if (this.instance) {
|
||||||
var vertexShader = '';
|
|
||||||
|
|
||||||
if (this.fragmentShader && this.fragmentShader.instance) {
|
/**
|
||||||
fragmentShader = this.fragmentShader.instance;
|
* We already have an instance from Child Class
|
||||||
|
*/
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (
|
||||||
|
GameLib.Utils.UndefinedOrNull(this.vertexShader) ||
|
||||||
|
GameLib.Utils.UndefinedOrNull(this.vertexShader.instance)
|
||||||
|
) {
|
||||||
|
console.warn('shader material ' + this.name + 'not ready for instance - needs a vertex shader');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.vertexShader && this.vertexShader.instance) {
|
if (
|
||||||
vertexShader = this.vertexShader.instance;
|
GameLib.Utils.UndefinedOrNull(this.fragmentShader) ||
|
||||||
|
GameLib.Utils.UndefinedOrNull(this.fragmentShader.instance)
|
||||||
|
) {
|
||||||
|
console.warn('shader material ' + this.name + 'not ready for instance - needs a fragment shader');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instance = new THREE.ShaderMaterial(
|
this.instance = new THREE.ShaderMaterial(
|
||||||
|
@ -75,23 +90,26 @@ GameLib.D3.Material.Shader.prototype.createInstance = function() {
|
||||||
defaultAttributeValues : this.defaultAttributeValues,
|
defaultAttributeValues : this.defaultAttributeValues,
|
||||||
extensions : this.extensions,
|
extensions : this.extensions,
|
||||||
fog : this.fog,
|
fog : this.fog,
|
||||||
fragmentShader : fragmentShader,
|
fragmentShader : this.fragmentShader.instance,
|
||||||
linewidth : this.linewidth,
|
linewidth : this.linewidth,
|
||||||
morphTargets : this.morphTargets,
|
morphTargets : this.morphTargets,
|
||||||
morphNormals : this.morphNormals,
|
morphNormals : this.morphNormals,
|
||||||
skinning : this.skinning,
|
skinning : this.skinning,
|
||||||
uniforms : this.uniforms,
|
uniforms : this.uniforms,
|
||||||
vertexColors : this.vertexColors,
|
vertexColors : this.vertexColors,
|
||||||
vertexShader : vertexShader,
|
vertexShader : this.vertexShader.instance,
|
||||||
wireframe : this.wireframe,
|
wireframe : this.wireframe,
|
||||||
wireframeLinewidth : this.wireframeLinewidth
|
wireframeLinewidth : this.wireframeLinewidth
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.index0AttributeName)) {
|
if (GameLib.Utils.Defined(this.index0AttributeName)) {
|
||||||
this.instance.index0AttributeName = this.index0AttributeName;
|
this.instance.index0AttributeName = this.index0AttributeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('shader material instance created');
|
||||||
|
|
||||||
GameLib.D3.Material.prototype.createInstance.call(this);
|
GameLib.D3.Material.prototype.createInstance.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,7 +119,19 @@ GameLib.D3.Material.Shader.prototype.createInstance = function() {
|
||||||
GameLib.D3.Material.Shader.prototype.updateInstance = function(property) {
|
GameLib.D3.Material.Shader.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
if (!this.instance) {
|
if (!this.instance) {
|
||||||
console.warn('shader material not ready');
|
|
||||||
|
if (
|
||||||
|
property === 'vertexShader' ||
|
||||||
|
property === 'fragmentShader'
|
||||||
|
) {
|
||||||
|
this.createInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If we don't return here - we risk storing this incomplete type with the entity..
|
||||||
|
*/
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === 'clipping') {
|
if (property === 'clipping') {
|
||||||
|
@ -125,8 +155,13 @@ GameLib.D3.Material.Shader.prototype.updateInstance = function(property) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === 'fragmentShader') {
|
if (property === 'fragmentShader') {
|
||||||
|
|
||||||
|
if (this.fragmentShader && this.fragmentShader.instance) {
|
||||||
this.instance.fragmentShader = this.fragmentShader.instance;
|
this.instance.fragmentShader = this.fragmentShader.instance;
|
||||||
this.instance.needsUpdate = true;
|
this.instance.needsUpdate = true;
|
||||||
|
} else {
|
||||||
|
console.warn('fragment shader for material has been removed or not linked - using last valid fragment shader');
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,8 +201,14 @@ GameLib.D3.Material.Shader.prototype.updateInstance = function(property) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === 'vertexShader') {
|
if (property === 'vertexShader') {
|
||||||
|
|
||||||
|
if (this.vertexShader && this.vertexShader.instance) {
|
||||||
this.instance.vertexShader = this.vertexShader.instance;
|
this.instance.vertexShader = this.vertexShader.instance;
|
||||||
this.instance.needsUpdate = true;
|
this.instance.needsUpdate = true;
|
||||||
|
} else {
|
||||||
|
console.warn('vertex shader for material has been removed or not linked - using last valid vertex shader');
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,15 +39,20 @@ GameLib.D3.Material.Shader.Raw.prototype.constructor = GameLib.D3.Material.Shade
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Material.Shader.Raw.prototype.createInstance = function() {
|
GameLib.D3.Material.Shader.Raw.prototype.createInstance = function() {
|
||||||
|
|
||||||
var fragmentShader = '';
|
if (
|
||||||
var vertexShader = '';
|
GameLib.Utils.UndefinedOrNull(this.vertexShader) ||
|
||||||
|
GameLib.Utils.UndefinedOrNull(this.vertexShader.instance)
|
||||||
if (this.fragmentShader && this.fragmentShader.instance) {
|
) {
|
||||||
fragmentShader = this.fragmentShader.instance;
|
console.warn('shader material ' + this.name + 'not ready for instance - needs a vertex shader');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.vertexShader && this.vertexShader.instance) {
|
if (
|
||||||
vertexShader = this.vertexShader.instance;
|
GameLib.Utils.UndefinedOrNull(this.fragmentShader) ||
|
||||||
|
GameLib.Utils.UndefinedOrNull(this.fragmentShader.instance)
|
||||||
|
) {
|
||||||
|
console.warn('shader material ' + this.name + 'not ready for instance - needs a fragment shader');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instance = new THREE.RawShaderMaterial(
|
this.instance = new THREE.RawShaderMaterial(
|
||||||
|
@ -56,24 +61,20 @@ GameLib.D3.Material.Shader.Raw.prototype.createInstance = function() {
|
||||||
defaultAttributeValues : this.defaultAttributeValues,
|
defaultAttributeValues : this.defaultAttributeValues,
|
||||||
extensions : this.extensions,
|
extensions : this.extensions,
|
||||||
fog : this.fog,
|
fog : this.fog,
|
||||||
fragmentShader : fragmentShader,
|
fragmentShader : this.fragmentShader.instance,
|
||||||
linewidth : this.linewidth,
|
linewidth : this.linewidth,
|
||||||
morphTargets : this.morphTargets,
|
morphTargets : this.morphTargets,
|
||||||
morphNormals : this.morphNormals,
|
morphNormals : this.morphNormals,
|
||||||
skinning : this.skinning,
|
skinning : this.skinning,
|
||||||
uniforms : this.uniforms,
|
uniforms : this.uniforms,
|
||||||
vertexColors : this.vertexColors,
|
vertexColors : this.vertexColors,
|
||||||
vertexShader : vertexShader,
|
vertexShader : this.vertexShader.instance,
|
||||||
wireframe : this.wireframe,
|
wireframe : this.wireframe,
|
||||||
wireframeLinewidth : this.wireframeLinewidth
|
wireframeLinewidth : this.wireframeLinewidth
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (GameLib.Utils.Defined(this.index0AttributeName)) {
|
GameLib.D3.Material.Shader.prototype.createInstance.call(this);
|
||||||
this.instance.index0AttributeName = this.index0AttributeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.D3.Material.prototype.createInstance.call(this);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -79,12 +79,12 @@ GameLib.D3.Scene = function (
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (typeof this.fog !== 'string') {
|
if (this.fog instanceof GameLib.D3.API.Fog) {
|
||||||
this.fog = new GameLib.D3.Fog(
|
this.fog = new GameLib.D3.Fog(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
this.fog
|
this.fog
|
||||||
)
|
)
|
||||||
}
|
};
|
||||||
|
|
||||||
this.gridColor = new GameLib.Color(
|
this.gridColor = new GameLib.Color(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
|
|
|
@ -22,10 +22,16 @@ GameLib.D3.Shader = function(
|
||||||
apiShader.name,
|
apiShader.name,
|
||||||
apiShader.shaderType,
|
apiShader.shaderType,
|
||||||
apiShader.parentEntity,
|
apiShader.parentEntity,
|
||||||
|
apiShader.parentMaterialShader,
|
||||||
apiShader.code
|
apiShader.code
|
||||||
);
|
);
|
||||||
|
|
||||||
GameLib.Component.call(this);
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
{
|
||||||
|
parentMaterialShader : GameLib.D3.Material.Shader
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Shader.prototype = Object.create(GameLib.CustomCode.prototype);
|
GameLib.D3.Shader.prototype = Object.create(GameLib.CustomCode.prototype);
|
||||||
|
@ -58,6 +64,17 @@ GameLib.D3.Shader.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
if (property === 'code') {
|
if (property === 'code') {
|
||||||
this.instance = this.code;
|
this.instance = this.code;
|
||||||
|
|
||||||
|
if (this.parentMaterialShader && this.parentMaterialShader.instance) {
|
||||||
|
|
||||||
|
this.parentMaterialShader.instance.program.destroy();
|
||||||
|
|
||||||
|
// this.parentMaterialShader.instance.needsUpdate = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.warn('parent material shader not running or linked');
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +91,7 @@ GameLib.D3.Shader.prototype.toApiObject = function() {
|
||||||
this.name,
|
this.name,
|
||||||
this.shaderType,
|
this.shaderType,
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity),
|
GameLib.Utils.IdOrNull(this.parentEntity),
|
||||||
|
GameLib.Utils.IdOrNull(this.parentMaterialShader),
|
||||||
this.code
|
this.code
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1205,6 +1205,7 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
'basic': GameLib.D3.API.Material.MATERIAL_TYPE_BASIC,
|
'basic': GameLib.D3.API.Material.MATERIAL_TYPE_BASIC,
|
||||||
'phong': GameLib.D3.API.Material.MATERIAL_TYPE_PHONG,
|
'phong': GameLib.D3.API.Material.MATERIAL_TYPE_PHONG,
|
||||||
'shader': GameLib.D3.API.Material.MATERIAL_TYPE_SHADER,
|
'shader': GameLib.D3.API.Material.MATERIAL_TYPE_SHADER,
|
||||||
|
'raw shader': GameLib.D3.API.Material.MATERIAL_TYPE_SHADER_RAW,
|
||||||
'points': GameLib.D3.API.Material.MATERIAL_TYPE_POINTS
|
'points': GameLib.D3.API.Material.MATERIAL_TYPE_POINTS
|
||||||
// 'toon': GameLib.D3.API.Material.MATERIAL_TYPE_TOON,
|
// 'toon': GameLib.D3.API.Material.MATERIAL_TYPE_TOON,
|
||||||
// 'line basic' : GameLib.D3.API.Material.MATERIAL_TYPE_LINE_BASIC
|
// 'line basic' : GameLib.D3.API.Material.MATERIAL_TYPE_LINE_BASIC
|
||||||
|
|
|
@ -28,6 +28,8 @@ GameLib.System.Render = function(
|
||||||
|
|
||||||
this.excludeFromEnvironmentSubscription = null;
|
this.excludeFromEnvironmentSubscription = null;
|
||||||
|
|
||||||
|
this.shaderUpdateSubscription = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Images
|
* Images
|
||||||
*/
|
*/
|
||||||
|
@ -119,6 +121,11 @@ GameLib.System.Render.prototype.start = function() {
|
||||||
this.setActiveRenderConfiguration
|
this.setActiveRenderConfiguration
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.shaderUpdateSubscription = GameLib.Event.Subscribe(
|
||||||
|
GameLib.Event.SHADER_UPDATE,
|
||||||
|
this.shaderUpdate.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
// this.delayedInstanceEncounteredSubscription = GameLib.Event.Subscribe(
|
// this.delayedInstanceEncounteredSubscription = GameLib.Event.Subscribe(
|
||||||
// GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED,
|
// GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED,
|
||||||
// this.delayedInstanceEncountered.bind(this)
|
// this.delayedInstanceEncountered.bind(this)
|
||||||
|
@ -290,6 +297,19 @@ GameLib.System.Render.prototype.windowResize = function(data) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.System.Render.prototype.shaderUpdate = function(data) {
|
||||||
|
|
||||||
|
this.activeRenderConfiguration.activeScenes.map(
|
||||||
|
function(scene){
|
||||||
|
this.activeRenderConfiguration.activeRenderer.instance.compile(
|
||||||
|
scene.instance,
|
||||||
|
this.activeRenderConfiguration.activeCamera.instance
|
||||||
|
);
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.System.Render.prototype.textureUpdated = function(data) {
|
GameLib.System.Render.prototype.textureUpdated = function(data) {
|
||||||
|
|
||||||
GameLib.EntityManager.Instance.queryComponentsByConstructor(GameLib.D3.Material).map(
|
GameLib.EntityManager.Instance.queryComponentsByConstructor(GameLib.D3.Material).map(
|
||||||
|
@ -732,6 +752,8 @@ GameLib.System.Render.prototype.stop = function() {
|
||||||
*/
|
*/
|
||||||
this.textureUpdatedSubscription.remove();
|
this.textureUpdatedSubscription.remove();
|
||||||
|
|
||||||
|
this.shaderUpdateSubscription.remove();
|
||||||
|
|
||||||
// this.delayedInstanceEncounteredSubscription.remove();
|
// this.delayedInstanceEncounteredSubscription.remove();
|
||||||
|
|
||||||
// window.removeEventListener(
|
// window.removeEventListener(
|
||||||
|
|
|
@ -864,7 +864,7 @@ GameLib.System.Storage.prototype.loadImage = function(data, callback, errorCallb
|
||||||
|
|
||||||
if (this.response.type.indexOf('application/json') !== -1) {
|
if (this.response.type.indexOf('application/json') !== -1) {
|
||||||
|
|
||||||
var base64 = 'iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QoWEQMQBXD4hQAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAABRSURBVGje7c8xDQAwCAAwmA3koA/PU8FB0jpo1nRc9uI4AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBgX0fjEoBa8xN1z4AAAAASUVORK5CYII=';
|
var base64 = 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gIPDBcYqg62uwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAaSURBVCjPY/z//z8DKYCJgUQwqmFUw9DRAABVbQMdny4VogAAAABJRU5ErkJggg==';
|
||||||
|
|
||||||
function fixBinary (bin) {
|
function fixBinary (bin) {
|
||||||
var length = bin.length;
|
var length = bin.length;
|
||||||
|
|
Loading…
Reference in New Issue