Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babylonjs-serializers

Package Overview
Dependencies
Maintainers
1
Versions
635
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babylonjs-serializers - npm Package Compare versions

Comparing version 3.1.0-alpha3.6 to 3.1.0-alpha3.7

18

babylonjs.serializers.js

@@ -22,3 +22,3 @@ var babylonDependency; try { babylonDependency = BABYLON || (typeof require !== 'undefined' && require("../babylon.max")); } catch (e) { babylonDependency = BABYLON || (typeof require !== 'undefined' && require("babylonjs")); }

(function (BABYLON) {
var OBJExport = (function () {
var OBJExport = /** @class */ (function () {
function OBJExport() {

@@ -40,5 +40,6 @@ }

//Uses the position of the item in the scene, to the file (this back to normal in the end)
var lastMatrix = null;
if (globalposition) {
var newMatrix = BABYLON.Matrix.Translation(mesh[j].position.x, mesh[j].position.y, mesh[j].position.z);
var lastMatrix = BABYLON.Matrix.Translation(-(mesh[j].position.x), -(mesh[j].position.y), -(mesh[j].position.z));
lastMatrix = BABYLON.Matrix.Translation(-(mesh[j].position.x), -(mesh[j].position.y), -(mesh[j].position.z));
mesh[j].bakeTransformIntoVertices(newMatrix);

@@ -49,5 +50,11 @@ }

if (materials) {
output.push("usemtl " + mesh[j].material.id);
var mat = mesh[j].material;
if (mat) {
output.push("usemtl " + mat.id);
}
}
var g = mesh[j].geometry;
if (!g) {
continue;
}
var trunkVerts = g.getVerticesData('position');

@@ -58,2 +65,5 @@ var trunkNormals = g.getVerticesData('normal');

var curV = 0;
if (!trunkVerts || !trunkNormals || !trunkUV || !trunkFaces) {
continue;
}
for (var i = 0; i < trunkVerts.length; i += 3) {

@@ -75,3 +85,3 @@ output.push("v " + trunkVerts[i] + " " + trunkVerts[i + 1] + " " + trunkVerts[i + 2]);

//back de previous matrix, to not change the original mesh in the scene
if (globalposition) {
if (globalposition && lastMatrix) {
mesh[j].bakeTransformIntoVertices(lastMatrix);

@@ -78,0 +88,0 @@ }

@@ -1,1 +0,1 @@

var babylonDependency;try{babylonDependency=BABYLON||"undefined"!=typeof require&&require("../babylon.max")}catch(e){babylonDependency=BABYLON||"undefined"!=typeof require&&require("babylonjs")}var BABYLON=babylonDependency,__decorate=this&&this.__decorate||function(e,t,o,r){var n,i=arguments.length,u=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(u=(i<3?n(u):i>3?n(t,o,u):n(t,o))||u);return i>3&&u&&Object.defineProperty(t,o,u),u},__extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])};return function(t,o){function r(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}})(),BABYLON;!(function(e){var t=(function(){function t(){}return t.OBJ=function(t,o,r,n){var i=[],u=1;o&&(r||(r="mat"),i.push("mtllib "+r+".mtl"));for(var s=0;s<t.length;s++){if(i.push("g object"+s),i.push("o object_"+s),n){var a=e.Matrix.Translation(t[s].position.x,t[s].position.y,t[s].position.z),p=e.Matrix.Translation(-t[s].position.x,-t[s].position.y,-t[s].position.z);t[s].bakeTransformIntoVertices(a)}o&&i.push("usemtl "+t[s].material.id);for(var c=t[s].geometry,f=c.getVerticesData("position"),l=c.getVerticesData("normal"),d=c.getVerticesData("uv"),h=c.getIndices(),m=0,b=0;b<f.length;b+=3)i.push("v "+f[b]+" "+f[b+1]+" "+f[b+2]),m++;for(b=0;b<l.length;b+=3)i.push("vn "+l[b]+" "+l[b+1]+" "+l[b+2]);for(b=0;b<d.length;b+=2)i.push("vt "+d[b]+" "+d[b+1]);for(b=0;b<h.length;b+=3)i.push("f "+(h[b+2]+u)+"/"+(h[b+2]+u)+"/"+(h[b+2]+u)+" "+(h[b+1]+u)+"/"+(h[b+1]+u)+"/"+(h[b+1]+u)+" "+(h[b]+u)+"/"+(h[b]+u)+"/"+(h[b]+u));n&&t[s].bakeTransformIntoVertices(p),u+=m}return i.join("\n")},t.MTL=function(e){var t=[],o=e.material;t.push("newmtl mat1"),t.push(" Ns "+o.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+o.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+o.ambientColor.r.toFixed(4)+" "+o.ambientColor.g.toFixed(4)+" "+o.ambientColor.b.toFixed(4)),t.push(" Kd "+o.diffuseColor.r.toFixed(4)+" "+o.diffuseColor.g.toFixed(4)+" "+o.diffuseColor.b.toFixed(4)),t.push(" Ks "+o.specularColor.r.toFixed(4)+" "+o.specularColor.g.toFixed(4)+" "+o.specularColor.b.toFixed(4)),t.push(" Ke "+o.emissiveColor.r.toFixed(4)+" "+o.emissiveColor.g.toFixed(4)+" "+o.emissiveColor.b.toFixed(4));return o.ambientTexture&&t.push(" map_Ka "+o.ambientTexture.name),o.diffuseTexture&&t.push(" map_Kd "+o.diffuseTexture.name),o.specularTexture&&t.push(" map_Ks "+o.specularTexture.name),o.bumpTexture&&t.push(" map_bump -imfchan z "+o.bumpTexture.name),o.opacityTexture&&t.push(" map_d "+o.opacityTexture.name),t.join("\n")},t})();e.OBJExport=t})(BABYLON||(BABYLON={})),(function(e,t){e&&e.BABYLON||("object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.BJSSerializers=t():e.BABYLON=t())})(this,(function(){return BABYLON}));
var babylonDependency;try{babylonDependency=BABYLON||"undefined"!=typeof require&&require("../babylon.max")}catch(e){babylonDependency=BABYLON||"undefined"!=typeof require&&require("babylonjs")}var BABYLON=babylonDependency,__decorate=this&&this.__decorate||function(e,t,o,r){var n,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var u=e.length-1;u>=0;u--)(n=e[u])&&(a=(i<3?n(a):i>3?n(t,o,a):n(t,o))||a);return i>3&&a&&Object.defineProperty(t,o,a),a},__extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])};return function(t,o){function r(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}})(),BABYLON;!(function(e){var t=(function(){function t(){}return t.OBJ=function(t,o,r,n){var i=[],a=1;o&&(r||(r="mat"),i.push("mtllib "+r+".mtl"));for(var u=0;u<t.length;u++){i.push("g object"+u),i.push("o object_"+u);var s=null;if(n){var p=e.Matrix.Translation(t[u].position.x,t[u].position.y,t[u].position.z);s=e.Matrix.Translation(-t[u].position.x,-t[u].position.y,-t[u].position.z),t[u].bakeTransformIntoVertices(p)}if(o){var f=t[u].material;f&&i.push("usemtl "+f.id)}var c=t[u].geometry;if(c){var l=c.getVerticesData("position"),d=c.getVerticesData("normal"),h=c.getVerticesData("uv"),m=c.getIndices(),b=0;if(l&&d&&h&&m){for(var x=0;x<l.length;x+=3)i.push("v "+l[x]+" "+l[x+1]+" "+l[x+2]),b++;for(x=0;x<d.length;x+=3)i.push("vn "+d[x]+" "+d[x+1]+" "+d[x+2]);for(x=0;x<h.length;x+=2)i.push("vt "+h[x]+" "+h[x+1]);for(x=0;x<m.length;x+=3)i.push("f "+(m[x+2]+a)+"/"+(m[x+2]+a)+"/"+(m[x+2]+a)+" "+(m[x+1]+a)+"/"+(m[x+1]+a)+"/"+(m[x+1]+a)+" "+(m[x]+a)+"/"+(m[x]+a)+"/"+(m[x]+a));n&&s&&t[u].bakeTransformIntoVertices(s),a+=b}}}return i.join("\n")},t.MTL=function(e){var t=[],o=e.material;t.push("newmtl mat1"),t.push(" Ns "+o.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+o.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+o.ambientColor.r.toFixed(4)+" "+o.ambientColor.g.toFixed(4)+" "+o.ambientColor.b.toFixed(4)),t.push(" Kd "+o.diffuseColor.r.toFixed(4)+" "+o.diffuseColor.g.toFixed(4)+" "+o.diffuseColor.b.toFixed(4)),t.push(" Ks "+o.specularColor.r.toFixed(4)+" "+o.specularColor.g.toFixed(4)+" "+o.specularColor.b.toFixed(4)),t.push(" Ke "+o.emissiveColor.r.toFixed(4)+" "+o.emissiveColor.g.toFixed(4)+" "+o.emissiveColor.b.toFixed(4));return o.ambientTexture&&t.push(" map_Ka "+o.ambientTexture.name),o.diffuseTexture&&t.push(" map_Kd "+o.diffuseTexture.name),o.specularTexture&&t.push(" map_Ks "+o.specularTexture.name),o.bumpTexture&&t.push(" map_bump -imfchan z "+o.bumpTexture.name),o.opacityTexture&&t.push(" map_d "+o.opacityTexture.name),t.join("\n")},t})();e.OBJExport=t})(BABYLON||(BABYLON={})),(function(e,t){e&&e.BABYLON||("object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.BJSSerializers=t():e.BABYLON=t())})(this,(function(){return BABYLON}));

@@ -7,3 +7,3 @@ {

"description": "The Babylon.js serializers library is an extension you can use to serialize Babylon scenes.",
"version": "3.1.0-alpha3.6",
"version": "3.1.0-alpha3.7",
"repository": {

@@ -10,0 +10,0 @@ "type": "git",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc