mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 12:28:02 +02:00
grid pattern
This commit is contained in:
parent
93516423bb
commit
b2f1657096
2 changed files with 22 additions and 27 deletions
Binary file not shown.
After Width: | Height: | Size: 8.4 KiB |
|
@ -11,7 +11,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
var SHAPETYPE_TO_SHAPE = {
|
var SHAPETYPE_TO_SHAPE = {
|
||||||
"sphere": "Sphere",
|
|
||||||
"box": "Cube",
|
"box": "Cube",
|
||||||
"ellipsoid": "Sphere",
|
"ellipsoid": "Sphere",
|
||||||
"cylinder-y": "Cylinder",
|
"cylinder-y": "Cylinder",
|
||||||
|
@ -23,13 +22,23 @@ function getEntityShapePropertiesForType(properties) {
|
||||||
if (SHAPETYPE_TO_SHAPE[properties.shapeType]) {
|
if (SHAPETYPE_TO_SHAPE[properties.shapeType]) {
|
||||||
return {
|
return {
|
||||||
type: "Shape",
|
type: "Shape",
|
||||||
shape: SHAPETYPE_TO_SHAPE[properties.shapeType]
|
shape: SHAPETYPE_TO_SHAPE[properties.shapeType],
|
||||||
}
|
localDimensions: properties.localDimensions
|
||||||
|
};
|
||||||
} else if (properties.shapeType === "compound") {
|
} else if (properties.shapeType === "compound") {
|
||||||
return {
|
return {
|
||||||
type: "Model",
|
type: "Model",
|
||||||
modelURL: properties.compoundShapeURL
|
modelURL: properties.compoundShapeURL,
|
||||||
}
|
localDimensions: properties.localDimensions
|
||||||
|
};
|
||||||
|
} else if (properties.shapeType === "sphere") {
|
||||||
|
var sphereDiameter = Math.max(properties.localDimensions.x, properties.localDimensions.y,
|
||||||
|
properties.localDimensions.z);
|
||||||
|
return {
|
||||||
|
type: "Sphere",
|
||||||
|
modelURL: properties.compoundShapeURL,
|
||||||
|
localDimensions: {x: sphereDiameter, y: sphereDiameter, z: sphereDiameter}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -37,8 +46,9 @@ function getEntityShapePropertiesForType(properties) {
|
||||||
// Default properties
|
// Default properties
|
||||||
return {
|
return {
|
||||||
type: "Shape",
|
type: "Shape",
|
||||||
shape: "Cube"
|
shape: "Cube",
|
||||||
}
|
localDimensions: properties.localDimensions
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStringifiedEntityShapePropertiesForType(properties) {
|
function getStringifiedEntityShapePropertiesForType(properties) {
|
||||||
|
@ -65,17 +75,11 @@ EntityShape.prototype = {
|
||||||
|
|
||||||
overlayProperties.localPosition = Vec3.ZERO;
|
overlayProperties.localPosition = Vec3.ZERO;
|
||||||
overlayProperties.localRotation = Quat.IDENTITY;
|
overlayProperties.localRotation = Quat.IDENTITY;
|
||||||
overlayProperties.localDimensions = properties.localDimensions;
|
|
||||||
overlayProperties.canCastShadows = false;
|
overlayProperties.canCastShadows = false;
|
||||||
overlayProperties.parentID = this.entityID;
|
overlayProperties.parentID = this.entityID;
|
||||||
overlayProperties.collisionless = true;
|
overlayProperties.collisionless = true;
|
||||||
this.entity = Entities.addEntity(overlayProperties, "local");
|
this.entity = Entities.addEntity(overlayProperties, "local");
|
||||||
|
var PROJECTED_MATERIALS = false;
|
||||||
console.warn("created " + this.entity);
|
|
||||||
console.warn("SHAPETYPE = " + properties.shapeType);
|
|
||||||
console.warn("SHAPE = " + Entities.getEntityProperties(this.entity, "shape").shape);
|
|
||||||
|
|
||||||
|
|
||||||
this.materialEntity = Entities.addEntity({
|
this.materialEntity = Entities.addEntity({
|
||||||
type: "Material",
|
type: "Material",
|
||||||
localPosition: Vec3.ZERO,
|
localPosition: Vec3.ZERO,
|
||||||
|
@ -83,39 +87,31 @@ EntityShape.prototype = {
|
||||||
localDimensions: properties.localDimensions,
|
localDimensions: properties.localDimensions,
|
||||||
parentID: this.entity,
|
parentID: this.entity,
|
||||||
priority: 1,
|
priority: 1,
|
||||||
|
materialMappingMode: PROJECTED_MATERIALS ? "projected" : "uv",
|
||||||
materialURL: "materialData",
|
materialURL: "materialData",
|
||||||
materialData: JSON.stringify({
|
materialData: JSON.stringify({
|
||||||
materialVersion: 1,
|
materialVersion: 1,
|
||||||
materials: {
|
materials: {
|
||||||
albedo: [0.0, 0.0, 7.0],
|
albedo: [0.0, 0.0, 7.0],
|
||||||
unlit: true,
|
unlit: true,
|
||||||
opacity: 0.4
|
opacity: 0.4,
|
||||||
|
albedoMap: Script.resolvePath("../assets/images/materials/boxgridpatterncreatezonew.png")
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}, "local");
|
}, "local");
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function() {
|
update: function() {
|
||||||
var properties = Entities.getEntityProperties(this.entityID, REQUESTED_ENTITY_SHAPE_PROPERTIES);
|
var properties = Entities.getEntityProperties(this.entityID, REQUESTED_ENTITY_SHAPE_PROPERTIES);
|
||||||
var propertiesForTypeStringified = getStringifiedEntityShapePropertiesForType(properties);
|
var propertiesForTypeStringified = getStringifiedEntityShapePropertiesForType(properties);
|
||||||
if (propertiesForTypeStringified !== this.previousPropertiesForTypeStringified) {
|
if (propertiesForTypeStringified !== this.previousPropertiesForTypeStringified) {
|
||||||
this.previousPropertiesForTypeStringified = propertiesForTypeStringified;
|
this.previousPropertiesForTypeStringified = propertiesForTypeStringified;
|
||||||
console.warn("Clearing old properties");
|
|
||||||
this.clear();
|
this.clear();
|
||||||
this.initialize(properties, propertiesForTypeStringified);
|
this.initialize(properties, propertiesForTypeStringified);
|
||||||
} else {
|
} else {
|
||||||
Entities.editEntity(this.entity, {
|
Entities.editEntity(this.entity, {
|
||||||
localDimensions: properties.localDimensions,
|
localDimensions: JSON.parse(propertiesForTypeStringified).localDimensions,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//this.previousProperties = Entities.getEntityProperties(this.entityID, REQUESTED_ENTITY_SHAPE_PROPERTIES);
|
|
||||||
|
|
||||||
|
|
||||||
console.warn(JSON.stringify(this.previousProperties));
|
|
||||||
},
|
},
|
||||||
clear: function() {
|
clear: function() {
|
||||||
Entities.deleteEntity(this.materialEntity);
|
Entities.deleteEntity(this.materialEntity);
|
||||||
|
@ -192,7 +188,6 @@ EntityShapeVisualizer.prototype = {
|
||||||
});
|
});
|
||||||
|
|
||||||
deleteEntries.forEach(function(entityID) {
|
deleteEntries.forEach(function(entityID) {
|
||||||
console.warn("removing " + entityID);
|
|
||||||
this.removeEntity(entityID);
|
this.removeEntity(entityID);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue