loading curves from blender - saving to API again - point materials - awesome SHITgit diffgit diff!
parent
481cd05374
commit
b03cff08a6
|
@ -540,7 +540,7 @@ GameLib.D3.Material.prototype.createInstance = function(update) {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(!instance) ||
|
(!instance) ||
|
||||||
(instance && instance.materialType != this.materialType)
|
(instance && instance.type != this.materialType)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (this.materialType == GameLib.D3.Material.MATERIAL_TYPE_STANDARD) {
|
if (this.materialType == GameLib.D3.Material.MATERIAL_TYPE_STANDARD) {
|
||||||
|
@ -653,12 +653,67 @@ GameLib.D3.Material.prototype.createInstance = function(update) {
|
||||||
morphTargets: this.morphTargets,
|
morphTargets: this.morphTargets,
|
||||||
morphNormals: this.morphNormals
|
morphNormals: this.morphNormals
|
||||||
});
|
});
|
||||||
|
} else if (this.materialType == GameLib.D3.Material.MATERIAL_TYPE_POINTS) {
|
||||||
|
|
||||||
|
instance = new this.graphics.instance.PointsMaterial({
|
||||||
|
name: this.name,
|
||||||
|
opacity: this.opacity,
|
||||||
|
transparent: this.transparent,
|
||||||
|
blending: this.blending,
|
||||||
|
blendSrc: this.blendSrc,
|
||||||
|
blendDst: this.blendDst,
|
||||||
|
blendEquation: this.blendEquation,
|
||||||
|
depthTest: this.depthTest,
|
||||||
|
depthFunc: this.depthFunc,
|
||||||
|
depthWrite: this.depthWrite,
|
||||||
|
polygonOffset: this.polygonOffset,
|
||||||
|
polygonOffsetFactor: this.polygonOffsetFactor,
|
||||||
|
polygonOffsetUnits: this.polygonOffsetUnits,
|
||||||
|
alphaTest: this.alphaTest,
|
||||||
|
clippingPlanes: this.clippingPlanes,
|
||||||
|
clipShadows: this.clipShadows,
|
||||||
|
overdraw: this.overdraw,
|
||||||
|
visible: this.visible,
|
||||||
|
side: this.side,
|
||||||
|
color: new this.graphics.instance.Color(
|
||||||
|
this.color.r,
|
||||||
|
this.color.g,
|
||||||
|
this.color.b
|
||||||
|
),
|
||||||
|
size: this.pointSize,
|
||||||
|
sizeAttenuation: this.pointSizeAttenuation,
|
||||||
|
vertexColors: GameLib.D3.Material.TYPE_NO_COLORS,
|
||||||
|
fog: this.fog
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("material type is not implemented yet: " + this.materialType + " - material indexes could be screwed up");
|
console.log("material type is not implemented yet: " + this.materialType + " - material indexes could be screwed up");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (update) {
|
||||||
|
|
||||||
|
for (var property in instance) {
|
||||||
|
|
||||||
|
if (property == 'size') {
|
||||||
|
instance[property] = this.pointSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property == 'sizeAttenuation') {
|
||||||
|
instance[property] = this.pointSizeAttenuation;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.hasOwnProperty(property) &&
|
||||||
|
instance.hasOwnProperty(property)
|
||||||
|
) {
|
||||||
|
instance[property] = this[property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.needsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,7 @@ GameLib.D3.Mesh.API = function(
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh.TYPE_NORMAL = 0;
|
GameLib.D3.Mesh.TYPE_NORMAL = 0;
|
||||||
GameLib.D3.Mesh.TYPE_SKINNED = 1;
|
GameLib.D3.Mesh.TYPE_SKINNED = 1;
|
||||||
|
GameLib.D3.Mesh.TYPE_CURVE = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a mesh instance or updates it
|
* Creates a mesh instance or updates it
|
||||||
|
@ -299,6 +300,10 @@ GameLib.D3.Mesh.prototype.createInstance = function(update) {
|
||||||
instance = new this.graphics.instance.Mesh(instanceGeometry, instanceMaterial);
|
instance = new this.graphics.instance.Mesh(instanceGeometry, instanceMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.meshType == GameLib.D3.Mesh.TYPE_CURVE) {
|
||||||
|
instance = new this.graphics.instance.Points(instanceGeometry, instanceMaterial);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.meshType == GameLib.D3.Mesh.TYPE_SKINNED) {
|
if (this.meshType == GameLib.D3.Mesh.TYPE_SKINNED) {
|
||||||
|
|
||||||
var bones = this.skeleton.bones;
|
var bones = this.skeleton.bones;
|
||||||
|
|
|
@ -374,6 +374,7 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
gameLibTextureMap[map].texture = new GameLib.D3.Texture(
|
gameLibTextureMap[map].texture = new GameLib.D3.Texture(
|
||||||
new GameLib.D3.Texture.API(
|
new GameLib.D3.Texture.API(
|
||||||
apiTexture.id,
|
apiTexture.id,
|
||||||
|
map,
|
||||||
apiTexture.name,
|
apiTexture.name,
|
||||||
uploadUrl + '/' + apiTexture.imagePath,
|
uploadUrl + '/' + apiTexture.imagePath,
|
||||||
apiTexture.wrapS,
|
apiTexture.wrapS,
|
||||||
|
|
|
@ -43,3 +43,31 @@ GameLib.D3.TextureMaps = function TextureMaps(
|
||||||
this.roughness = roughness;
|
this.roughness = roughness;
|
||||||
this.specular = specular;
|
this.specular = specular;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.D3.TextureMaps.API = function TextureMaps(
|
||||||
|
alpha,
|
||||||
|
ao,
|
||||||
|
bump,
|
||||||
|
diffuse,
|
||||||
|
displacement,
|
||||||
|
emissive,
|
||||||
|
environment,
|
||||||
|
light,
|
||||||
|
metalness,
|
||||||
|
normal,
|
||||||
|
roughness,
|
||||||
|
specular
|
||||||
|
) {
|
||||||
|
this[GameLib.D3.Texture.TEXTURE_TYPE_ALPHA] == alpha;
|
||||||
|
this[GameLib.D3.Texture.TEXTURE_TYPE_AO] == ao;
|
||||||
|
this[GameLib.D3.Texture.TEXTURE_TYPE_BUMP] == bump;
|
||||||
|
this[GameLib.D3.Texture.TEXTURE_TYPE_DIFFUSE] == diffuse;
|
||||||
|
this[GameLib.D3.Texture.TEXTURE_TYPE_DISPLACEMENT] == displacement;
|
||||||
|
this[GameLib.D3.Texture.TEXTURE_TYPE_EMISSIVE] == emissive;
|
||||||
|
this[GameLib.D3.Texture.TEXTURE_TYPE_ENVIRONMENT] == environment;
|
||||||
|
this[GameLib.D3.Texture.TEXTURE_TYPE_LIGHT] == light;
|
||||||
|
this[GameLib.D3.Texture.TEXTURE_TYPE_METALNESS] == metalness;
|
||||||
|
this[GameLib.D3.Texture.TEXTURE_TYPE_NORMAL] == normal;
|
||||||
|
this[GameLib.D3.Texture.TEXTURE_TYPE_ROUGHNESS] == roughness;
|
||||||
|
this[GameLib.D3.Texture.TEXTURE_TYPE_SPECULAR] == specular;
|
||||||
|
};
|
|
@ -54,6 +54,7 @@ GameLib.D3.Texture.prototype.loadTexture = function(imageFactory) {
|
||||||
/**
|
/**
|
||||||
* Raw Texture API object - should always correspond with the Texture Schema
|
* Raw Texture API object - should always correspond with the Texture Schema
|
||||||
* @param id
|
* @param id
|
||||||
|
* @param typeId
|
||||||
* @param name
|
* @param name
|
||||||
* @param imagePath
|
* @param imagePath
|
||||||
* @param wrapS
|
* @param wrapS
|
||||||
|
@ -77,6 +78,7 @@ GameLib.D3.Texture.prototype.loadTexture = function(imageFactory) {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Texture.API = function(
|
GameLib.D3.Texture.API = function(
|
||||||
id,
|
id,
|
||||||
|
typeId,
|
||||||
name,
|
name,
|
||||||
imagePath,
|
imagePath,
|
||||||
wrapS,
|
wrapS,
|
||||||
|
@ -102,13 +104,18 @@ GameLib.D3.Texture.API = function(
|
||||||
}
|
}
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
|
if (GameLib.D3.Utils.UndefinedOrNull(typeId)) {
|
||||||
|
typeId = GameLib.D3.Texture.TEXTURE_TYPE_DIFFUSE;
|
||||||
|
}
|
||||||
|
this.typeId = typeId;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
||||||
name = 'Texture (' + image.name + ')';
|
name = 'Texture (' + typeId + ')';
|
||||||
}
|
}
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
if (GameLib.D3.Utils.UndefinedOrNull(imagePath)) {
|
if (GameLib.D3.Utils.UndefinedOrNull(imagePath)) {
|
||||||
throw new Error('Cannot create textures with no image path set');
|
imagePath = null;
|
||||||
}
|
}
|
||||||
this.imagePath = imagePath;
|
this.imagePath = imagePath;
|
||||||
|
|
||||||
|
@ -268,6 +275,19 @@ GameLib.D3.Texture.TYPE_RGBM7_ENCODING = 3004;
|
||||||
GameLib.D3.Texture.TYPE_RGBM16_ENCODING = 3005;
|
GameLib.D3.Texture.TYPE_RGBM16_ENCODING = 3005;
|
||||||
GameLib.D3.Texture.TYPE_RGBD_ENCODING = 3006; // MAXRANGE IS 256.
|
GameLib.D3.Texture.TYPE_RGBD_ENCODING = 3006; // MAXRANGE IS 256.
|
||||||
|
|
||||||
|
GameLib.D3.Texture.TEXTURE_TYPE_ALPHA = 'alpha';
|
||||||
|
GameLib.D3.Texture.TEXTURE_TYPE_AO = 'ao';
|
||||||
|
GameLib.D3.Texture.TEXTURE_TYPE_BUMP = 'bump';
|
||||||
|
GameLib.D3.Texture.TEXTURE_TYPE_DIFFUSE = 'diffuse';
|
||||||
|
GameLib.D3.Texture.TEXTURE_TYPE_DISPLACEMENT = 'displacement';
|
||||||
|
GameLib.D3.Texture.TEXTURE_TYPE_EMISSIVE = 'emissive';
|
||||||
|
GameLib.D3.Texture.TEXTURE_TYPE_ENVIRONMENT = 'environment';
|
||||||
|
GameLib.D3.Texture.TEXTURE_TYPE_LIGHT = 'light';
|
||||||
|
GameLib.D3.Texture.TEXTURE_TYPE_METALNESS = 'metalness';
|
||||||
|
GameLib.D3.Texture.TEXTURE_TYPE_NORMAL = 'normal';
|
||||||
|
GameLib.D3.Texture.TEXTURE_TYPE_ROUGHNESS = 'roughness';
|
||||||
|
GameLib.D3.Texture.TEXTURE_TYPE_SPECULAR = 'specular';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of our texture object
|
* Creates an instance of our texture object
|
||||||
* @returns {GameLib.D3.Texture|THREE.SoftwareRenderer.Texture|THREE.Texture|*|Texture}
|
* @returns {GameLib.D3.Texture|THREE.SoftwareRenderer.Texture|THREE.Texture|*|Texture}
|
||||||
|
|
Loading…
Reference in New Issue