@rings-webgpu/core 1.0.19 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rings.es.js +35 -37
- package/dist/rings.es.js.map +3 -3
- package/dist/rings.es.max.js +279 -83
- package/dist/rings.umd.js +39 -41
- package/dist/rings.umd.js.map +3 -3
- package/dist/rings.umd.max.js +279 -83
- package/dist/types/index.d.ts +3 -3
- package/dist/types/loader/parser/3dgs/loaders/index.d.ts +0 -1
- package/dist/types/loader/parser/OBJParser.d.ts +22 -0
- package/package.json +1 -1
- /package/dist/types/loader/parser/{3dgs/loaders/ply → ply}/PlyLoader.d.ts +0 -0
- /package/dist/types/loader/parser/{3dgs/loaders/ply → ply}/PlyTypes.d.ts +0 -0
- /package/dist/types/loader/parser/{3dgs/loaders/ply → ply}/PlyUtils.d.ts +0 -0
- /package/dist/types/loader/parser/{3dgs/loaders/ply → ply}/index.d.ts +0 -0
package/dist/rings.umd.max.js
CHANGED
|
@@ -25047,30 +25047,32 @@ struct InstanceData {
|
|
|
25047
25047
|
static genGSplatBounds(obj, bound) {
|
|
25048
25048
|
bound ||= new BoundingBox(Vector3.ZERO, Vector3.ZERO);
|
|
25049
25049
|
bound.setFromMinMax(this.maxVector, this.minVector);
|
|
25050
|
-
let
|
|
25051
|
-
if (!
|
|
25050
|
+
let gsplatRenderers = obj.getComponents(exports.GSplatRenderer);
|
|
25051
|
+
if (!gsplatRenderers) {
|
|
25052
25052
|
console.warn("genGSplatBounds: No GSplatRenderer found on object");
|
|
25053
25053
|
return bound;
|
|
25054
25054
|
}
|
|
25055
|
-
const
|
|
25056
|
-
|
|
25057
|
-
|
|
25058
|
-
|
|
25059
|
-
|
|
25060
|
-
|
|
25061
|
-
|
|
25062
|
-
|
|
25063
|
-
|
|
25064
|
-
|
|
25065
|
-
|
|
25066
|
-
|
|
25067
|
-
|
|
25068
|
-
|
|
25069
|
-
|
|
25070
|
-
|
|
25071
|
-
|
|
25055
|
+
for (const gsplatRenderer of gsplatRenderers) {
|
|
25056
|
+
const positions = gsplatRenderer.positions;
|
|
25057
|
+
const count = gsplatRenderer.fullCount;
|
|
25058
|
+
if (!positions || count === 0) {
|
|
25059
|
+
console.warn("genGSplatBounds: No position data available");
|
|
25060
|
+
return bound;
|
|
25061
|
+
}
|
|
25062
|
+
const matrix = obj.transform.worldMatrix;
|
|
25063
|
+
const point = new Vector3();
|
|
25064
|
+
for (let i = 0; i < count; i++) {
|
|
25065
|
+
const idx = i * 3;
|
|
25066
|
+
point.set(
|
|
25067
|
+
positions[idx + 0],
|
|
25068
|
+
positions[idx + 1],
|
|
25069
|
+
positions[idx + 2]
|
|
25070
|
+
);
|
|
25071
|
+
matrix.transformPoint(point, point);
|
|
25072
|
+
bound.expandByPoint(point);
|
|
25073
|
+
}
|
|
25074
|
+
bound.setFromMinMax(bound.min, bound.max);
|
|
25072
25075
|
}
|
|
25073
|
-
bound.setFromMinMax(bound.min, bound.max);
|
|
25074
25076
|
return bound;
|
|
25075
25077
|
}
|
|
25076
25078
|
static genMeshBounds(obj, bound) {
|
|
@@ -36933,6 +36935,8 @@ else if (typeof exports === 'object')
|
|
|
36933
36935
|
matLibs;
|
|
36934
36936
|
geometrys;
|
|
36935
36937
|
activeGeo;
|
|
36938
|
+
currentObjectName;
|
|
36939
|
+
currentMaterialName;
|
|
36936
36940
|
facesMaterialsIndex;
|
|
36937
36941
|
mtl;
|
|
36938
36942
|
mtlUrl;
|
|
@@ -36941,26 +36945,35 @@ else if (typeof exports === 'object')
|
|
|
36941
36945
|
this.source_normals = [];
|
|
36942
36946
|
this.source_tangents = [];
|
|
36943
36947
|
this.source_textureCoords = [];
|
|
36948
|
+
this.currentObjectName = "default";
|
|
36949
|
+
this.currentMaterialName = "";
|
|
36944
36950
|
this.matLibs = {};
|
|
36945
36951
|
this.geometrys = {};
|
|
36952
|
+
this.activeGeo = void 0;
|
|
36946
36953
|
this.textData = obj;
|
|
36947
36954
|
await Promise.all([this.parserOBJ(), this.loadMTL()]);
|
|
36948
36955
|
this.parser_mesh();
|
|
36949
36956
|
return `null`;
|
|
36950
36957
|
}
|
|
36951
36958
|
applyVector2(fi, sourceData, destData) {
|
|
36952
|
-
if (sourceData[fi] && sourceData[fi].length > 0) {
|
|
36959
|
+
if (fi >= 0 && sourceData[fi] && sourceData[fi].length > 0) {
|
|
36953
36960
|
destData.push(sourceData[fi][0]);
|
|
36954
|
-
destData.push(sourceData[fi][1]);
|
|
36961
|
+
destData.push(-sourceData[fi][1]);
|
|
36955
36962
|
} else {
|
|
36956
36963
|
destData.push(0);
|
|
36957
36964
|
destData.push(0);
|
|
36958
36965
|
}
|
|
36959
36966
|
}
|
|
36960
36967
|
applyVector3(fi, sourceData, destData) {
|
|
36961
|
-
|
|
36962
|
-
|
|
36963
|
-
|
|
36968
|
+
if (fi >= 0 && sourceData[fi] && sourceData[fi].length > 0) {
|
|
36969
|
+
destData.push(sourceData[fi][0]);
|
|
36970
|
+
destData.push(sourceData[fi][1]);
|
|
36971
|
+
destData.push(sourceData[fi][2]);
|
|
36972
|
+
} else {
|
|
36973
|
+
destData.push(0);
|
|
36974
|
+
destData.push(0);
|
|
36975
|
+
destData.push(0);
|
|
36976
|
+
}
|
|
36964
36977
|
}
|
|
36965
36978
|
applyVector4(fi, sourceData, destData) {
|
|
36966
36979
|
destData.push(sourceData[fi][0]);
|
|
@@ -36968,12 +36981,76 @@ else if (typeof exports === 'object')
|
|
|
36968
36981
|
destData.push(sourceData[fi][2]);
|
|
36969
36982
|
destData.push(sourceData[fi][3]);
|
|
36970
36983
|
}
|
|
36984
|
+
/**
|
|
36985
|
+
* Parse UV index with support for negative indices (OBJ format)
|
|
36986
|
+
* Similar to Three.js parseUVIndex method
|
|
36987
|
+
*/
|
|
36988
|
+
parseUVIndex(value, uvCount) {
|
|
36989
|
+
const index = parseInt(value, 10);
|
|
36990
|
+
if (index >= 0) {
|
|
36991
|
+
return index - 1;
|
|
36992
|
+
} else {
|
|
36993
|
+
return uvCount + index;
|
|
36994
|
+
}
|
|
36995
|
+
}
|
|
36996
|
+
/**
|
|
36997
|
+
* Parse vertex index with support for negative indices (OBJ format)
|
|
36998
|
+
*/
|
|
36999
|
+
parseVertexIndex(value, vertexCount) {
|
|
37000
|
+
const index = parseInt(value, 10);
|
|
37001
|
+
if (index >= 0) {
|
|
37002
|
+
return index - 1;
|
|
37003
|
+
} else {
|
|
37004
|
+
return vertexCount + index;
|
|
37005
|
+
}
|
|
37006
|
+
}
|
|
37007
|
+
/**
|
|
37008
|
+
* Parse normal index with support for negative indices (OBJ format)
|
|
37009
|
+
*/
|
|
37010
|
+
parseNormalIndex(value, normalCount) {
|
|
37011
|
+
const index = parseInt(value, 10);
|
|
37012
|
+
if (index >= 0) {
|
|
37013
|
+
return index - 1;
|
|
37014
|
+
} else {
|
|
37015
|
+
return normalCount + index;
|
|
37016
|
+
}
|
|
37017
|
+
}
|
|
37018
|
+
/**
|
|
37019
|
+
* Calculate face normal from three vertices using cross product
|
|
37020
|
+
* Similar to Three.js addFaceNormal method
|
|
37021
|
+
*/
|
|
37022
|
+
calculateFaceNormal(v0, v1, v2) {
|
|
37023
|
+
const edge1 = [
|
|
37024
|
+
v1[0] - v0[0],
|
|
37025
|
+
v1[1] - v0[1],
|
|
37026
|
+
v1[2] - v0[2]
|
|
37027
|
+
];
|
|
37028
|
+
const edge2 = [
|
|
37029
|
+
v2[0] - v0[0],
|
|
37030
|
+
v2[1] - v0[1],
|
|
37031
|
+
v2[2] - v0[2]
|
|
37032
|
+
];
|
|
37033
|
+
const normal = [
|
|
37034
|
+
edge1[1] * edge2[2] - edge1[2] * edge2[1],
|
|
37035
|
+
edge1[2] * edge2[0] - edge1[0] * edge2[2],
|
|
37036
|
+
edge1[0] * edge2[1] - edge1[1] * edge2[0]
|
|
37037
|
+
];
|
|
37038
|
+
const length = Math.sqrt(
|
|
37039
|
+
normal[0] * normal[0] + normal[1] * normal[1] + normal[2] * normal[2]
|
|
37040
|
+
);
|
|
37041
|
+
if (length > 0) {
|
|
37042
|
+
normal[0] /= length;
|
|
37043
|
+
normal[1] /= length;
|
|
37044
|
+
normal[2] /= length;
|
|
37045
|
+
}
|
|
37046
|
+
return normal;
|
|
37047
|
+
}
|
|
36971
37048
|
async loadMTL() {
|
|
36972
37049
|
let fileLoad = new FileLoader();
|
|
36973
37050
|
let sourceData = await fileLoad.loadTxt(this.baseUrl + this.mtlUrl);
|
|
36974
37051
|
let sourceStr = sourceData[`data`];
|
|
36975
37052
|
let mat;
|
|
36976
|
-
let str = sourceStr.split(
|
|
37053
|
+
let str = sourceStr.split(/\r?\n/);
|
|
36977
37054
|
for (let i = 0; i < str.length; i++) {
|
|
36978
37055
|
let line = str[i];
|
|
36979
37056
|
var commentStart = line.indexOf("#");
|
|
@@ -37024,20 +37101,41 @@ else if (typeof exports === 'object')
|
|
|
37024
37101
|
}
|
|
37025
37102
|
async load_textures() {
|
|
37026
37103
|
}
|
|
37104
|
+
getGeometryKey(objectName, materialName) {
|
|
37105
|
+
const objName = (objectName ?? this.currentObjectName ?? "default") || "default";
|
|
37106
|
+
const matName = materialName ?? this.currentMaterialName ?? "";
|
|
37107
|
+
const matKey = matName.length > 0 ? matName : "default";
|
|
37108
|
+
return `${objName}::${matKey}`;
|
|
37109
|
+
}
|
|
37110
|
+
ensureActiveGeo(objectName, materialName) {
|
|
37111
|
+
const objName = (objectName ?? this.currentObjectName ?? "default") || "default";
|
|
37112
|
+
const matName = materialName ?? this.currentMaterialName ?? "";
|
|
37113
|
+
const geoKey = this.getGeometryKey(objName, matName);
|
|
37114
|
+
if (!this.geometrys[geoKey]) {
|
|
37115
|
+
this.geometrys[geoKey] = {
|
|
37116
|
+
type: objName,
|
|
37117
|
+
name: geoKey,
|
|
37118
|
+
source_mat: matName,
|
|
37119
|
+
source_faces: []
|
|
37120
|
+
};
|
|
37121
|
+
} else if (this.geometrys[geoKey].source_mat !== matName) {
|
|
37122
|
+
this.geometrys[geoKey].source_mat = matName;
|
|
37123
|
+
}
|
|
37124
|
+
this.activeGeo = this.geometrys[geoKey];
|
|
37125
|
+
}
|
|
37027
37126
|
parserLine(line) {
|
|
37028
37127
|
var commentStart = line.indexOf("#");
|
|
37029
37128
|
if (commentStart != -1) {
|
|
37030
37129
|
if (line.indexOf(`# object`) != -1) {
|
|
37031
|
-
|
|
37032
|
-
|
|
37033
|
-
|
|
37034
|
-
this.
|
|
37035
|
-
|
|
37036
|
-
|
|
37037
|
-
|
|
37038
|
-
|
|
37039
|
-
}
|
|
37040
|
-
this.geometrys[geoName] = this.activeGeo;
|
|
37130
|
+
const commentParts = line.split(/\s+/);
|
|
37131
|
+
const type = commentParts[1] || "default";
|
|
37132
|
+
const geoName = commentParts[2] || "default";
|
|
37133
|
+
this.currentObjectName = geoName;
|
|
37134
|
+
this.activeGeo = void 0;
|
|
37135
|
+
this.ensureActiveGeo(geoName, this.currentMaterialName);
|
|
37136
|
+
if (this.activeGeo) {
|
|
37137
|
+
this.activeGeo.type = type;
|
|
37138
|
+
}
|
|
37041
37139
|
}
|
|
37042
37140
|
line = line.substring(0, commentStart);
|
|
37043
37141
|
}
|
|
@@ -37072,33 +37170,30 @@ else if (typeof exports === 'object')
|
|
|
37072
37170
|
normal: []
|
|
37073
37171
|
};
|
|
37074
37172
|
for (var i = 1; i < splitedLine.length; ++i) {
|
|
37075
|
-
var
|
|
37076
|
-
|
|
37077
|
-
|
|
37078
|
-
|
|
37079
|
-
|
|
37080
|
-
|
|
37081
|
-
|
|
37082
|
-
|
|
37083
|
-
} else if (splitedFaceIndices.length === 2) {
|
|
37084
|
-
face.indices.push(splitedFaceIndices[0]);
|
|
37085
|
-
face.texture.push(splitedFaceIndices[1]);
|
|
37086
|
-
} else if (splitedFaceIndices.length === 3) {
|
|
37087
|
-
face.indices.push(splitedFaceIndices[0]);
|
|
37088
|
-
face.texture.push(splitedFaceIndices[1]);
|
|
37089
|
-
face.normal.push(splitedFaceIndices[2]);
|
|
37090
|
-
}
|
|
37173
|
+
var vertexStr = splitedLine[i];
|
|
37174
|
+
if (vertexStr.length === 0) continue;
|
|
37175
|
+
var vertexParts = vertexStr.split("/");
|
|
37176
|
+
var positionIndex = vertexParts[0] || "";
|
|
37177
|
+
var textureIndex = vertexParts.length >= 2 ? vertexParts[1] || "" : "";
|
|
37178
|
+
var normalIndex = vertexParts.length >= 3 ? vertexParts[2] || "" : "";
|
|
37179
|
+
if (positionIndex.length === 0) {
|
|
37180
|
+
continue;
|
|
37091
37181
|
}
|
|
37182
|
+
face.indices.push(positionIndex);
|
|
37183
|
+
face.texture.push(textureIndex);
|
|
37184
|
+
face.normal.push(normalIndex);
|
|
37092
37185
|
}
|
|
37186
|
+
this.ensureActiveGeo();
|
|
37093
37187
|
this.activeGeo.source_faces.push(face);
|
|
37094
37188
|
} else if (splitedLine[0] === "usemtl") {
|
|
37095
|
-
this.
|
|
37189
|
+
this.currentMaterialName = splitedLine[1] || "";
|
|
37190
|
+
this.ensureActiveGeo(this.currentObjectName, this.currentMaterialName);
|
|
37096
37191
|
} else if (splitedLine[0] === `mtllib`) {
|
|
37097
37192
|
this.mtlUrl = splitedLine[1];
|
|
37098
37193
|
}
|
|
37099
37194
|
}
|
|
37100
37195
|
async parserOBJ() {
|
|
37101
|
-
let str = this.textData.split(
|
|
37196
|
+
let str = this.textData.split(/\r?\n/);
|
|
37102
37197
|
for (let i = 0; i < str.length; i++) {
|
|
37103
37198
|
const element = str[i];
|
|
37104
37199
|
this.parserLine(element);
|
|
@@ -37115,44 +37210,138 @@ else if (typeof exports === 'object')
|
|
|
37115
37210
|
geoData.uv_arr = [];
|
|
37116
37211
|
geoData.indeice_arr = [];
|
|
37117
37212
|
let index = 0;
|
|
37213
|
+
const vertexCount = this.source_vertices.length;
|
|
37214
|
+
const normalCount = this.source_normals.length;
|
|
37215
|
+
const uvCount = this.source_textureCoords.length;
|
|
37118
37216
|
for (let i = 0; i < geoData.source_faces.length; i++) {
|
|
37119
37217
|
const face = geoData.source_faces[i];
|
|
37120
|
-
let f0 =
|
|
37121
|
-
let f1 =
|
|
37122
|
-
let f2 =
|
|
37123
|
-
|
|
37124
|
-
|
|
37125
|
-
|
|
37126
|
-
|
|
37127
|
-
|
|
37128
|
-
|
|
37218
|
+
let f0 = this.parseVertexIndex(face.indices[0], vertexCount);
|
|
37219
|
+
let f1 = this.parseVertexIndex(face.indices[1], vertexCount);
|
|
37220
|
+
let f2 = this.parseVertexIndex(face.indices[2], vertexCount);
|
|
37221
|
+
const getNormalIndex = (value) => {
|
|
37222
|
+
if (!value || value.length === 0) {
|
|
37223
|
+
return -1;
|
|
37224
|
+
}
|
|
37225
|
+
const parsed = this.parseNormalIndex(value, normalCount);
|
|
37226
|
+
return Number.isFinite(parsed) && parsed >= 0 && parsed < normalCount ? parsed : -1;
|
|
37227
|
+
};
|
|
37228
|
+
const getUVIndex = (value) => {
|
|
37229
|
+
if (!value || value.length === 0) {
|
|
37230
|
+
return -1;
|
|
37231
|
+
}
|
|
37232
|
+
const parsed = this.parseUVIndex(value, uvCount);
|
|
37233
|
+
return Number.isFinite(parsed) && parsed >= 0 && parsed < uvCount ? parsed : -1;
|
|
37234
|
+
};
|
|
37235
|
+
let n0 = getNormalIndex(face.normal[0]);
|
|
37236
|
+
let n1 = getNormalIndex(face.normal[1]);
|
|
37237
|
+
let n2 = getNormalIndex(face.normal[2]);
|
|
37238
|
+
const needsFaceNormal = n0 < 0 || n1 < 0 || n2 < 0;
|
|
37239
|
+
let faceNormal = null;
|
|
37240
|
+
if (needsFaceNormal && f0 >= 0 && f1 >= 0 && f2 >= 0 && this.source_vertices[f0] && this.source_vertices[f1] && this.source_vertices[f2]) {
|
|
37241
|
+
faceNormal = this.calculateFaceNormal(
|
|
37242
|
+
this.source_vertices[f0],
|
|
37243
|
+
this.source_vertices[f1],
|
|
37244
|
+
this.source_vertices[f2]
|
|
37245
|
+
);
|
|
37246
|
+
}
|
|
37247
|
+
let u0 = getUVIndex(face.texture[0]);
|
|
37248
|
+
let u1 = getUVIndex(face.texture[1]);
|
|
37249
|
+
let u2 = getUVIndex(face.texture[2]);
|
|
37129
37250
|
this.applyVector3(f0, this.source_vertices, geoData.vertex_arr);
|
|
37130
|
-
|
|
37131
|
-
|
|
37251
|
+
if (n0 >= 0) {
|
|
37252
|
+
this.applyVector3(n0, this.source_normals, geoData.normal_arr);
|
|
37253
|
+
} else if (faceNormal) {
|
|
37254
|
+
geoData.normal_arr.push(faceNormal[0], faceNormal[1], faceNormal[2]);
|
|
37255
|
+
} else {
|
|
37256
|
+
geoData.normal_arr.push(0, 0, 0);
|
|
37257
|
+
}
|
|
37258
|
+
if (u0 >= 0) {
|
|
37259
|
+
this.applyVector2(u0, this.source_textureCoords, geoData.uv_arr);
|
|
37260
|
+
} else {
|
|
37261
|
+
geoData.uv_arr.push(0, 0);
|
|
37262
|
+
}
|
|
37132
37263
|
geoData.indeice_arr[index] = index++;
|
|
37133
37264
|
this.applyVector3(f1, this.source_vertices, geoData.vertex_arr);
|
|
37134
|
-
|
|
37135
|
-
|
|
37265
|
+
if (n1 >= 0) {
|
|
37266
|
+
this.applyVector3(n1, this.source_normals, geoData.normal_arr);
|
|
37267
|
+
} else if (faceNormal) {
|
|
37268
|
+
geoData.normal_arr.push(faceNormal[0], faceNormal[1], faceNormal[2]);
|
|
37269
|
+
} else {
|
|
37270
|
+
geoData.normal_arr.push(0, 0, 0);
|
|
37271
|
+
}
|
|
37272
|
+
if (u1 >= 0) {
|
|
37273
|
+
this.applyVector2(u1, this.source_textureCoords, geoData.uv_arr);
|
|
37274
|
+
} else {
|
|
37275
|
+
geoData.uv_arr.push(0, 0);
|
|
37276
|
+
}
|
|
37136
37277
|
geoData.indeice_arr[index] = index++;
|
|
37137
37278
|
this.applyVector3(f2, this.source_vertices, geoData.vertex_arr);
|
|
37138
|
-
|
|
37139
|
-
|
|
37279
|
+
if (n2 >= 0) {
|
|
37280
|
+
this.applyVector3(n2, this.source_normals, geoData.normal_arr);
|
|
37281
|
+
} else if (faceNormal) {
|
|
37282
|
+
geoData.normal_arr.push(faceNormal[0], faceNormal[1], faceNormal[2]);
|
|
37283
|
+
} else {
|
|
37284
|
+
geoData.normal_arr.push(0, 0, 0);
|
|
37285
|
+
}
|
|
37286
|
+
if (u2 >= 0) {
|
|
37287
|
+
this.applyVector2(u2, this.source_textureCoords, geoData.uv_arr);
|
|
37288
|
+
} else {
|
|
37289
|
+
geoData.uv_arr.push(0, 0);
|
|
37290
|
+
}
|
|
37140
37291
|
geoData.indeice_arr[index] = index++;
|
|
37141
37292
|
if (face.indices.length > 3) {
|
|
37142
|
-
let f3 =
|
|
37143
|
-
let n3 =
|
|
37144
|
-
let u3 =
|
|
37293
|
+
let f3 = this.parseVertexIndex(face.indices[3], vertexCount);
|
|
37294
|
+
let n3 = getNormalIndex(face.normal[3]);
|
|
37295
|
+
let u3 = getUVIndex(face.texture[3]);
|
|
37296
|
+
let faceNormal2 = null;
|
|
37297
|
+
if ((n0 < 0 || n2 < 0 || n3 < 0) && f0 >= 0 && f2 >= 0 && f3 >= 0 && this.source_vertices[f0] && this.source_vertices[f2] && this.source_vertices[f3]) {
|
|
37298
|
+
faceNormal2 = this.calculateFaceNormal(
|
|
37299
|
+
this.source_vertices[f0],
|
|
37300
|
+
this.source_vertices[f2],
|
|
37301
|
+
this.source_vertices[f3]
|
|
37302
|
+
);
|
|
37303
|
+
}
|
|
37145
37304
|
this.applyVector3(f0, this.source_vertices, geoData.vertex_arr);
|
|
37146
|
-
|
|
37147
|
-
|
|
37305
|
+
if (n0 >= 0) {
|
|
37306
|
+
this.applyVector3(n0, this.source_normals, geoData.normal_arr);
|
|
37307
|
+
} else if (faceNormal2) {
|
|
37308
|
+
geoData.normal_arr.push(faceNormal2[0], faceNormal2[1], faceNormal2[2]);
|
|
37309
|
+
} else {
|
|
37310
|
+
geoData.normal_arr.push(0, 0, 0);
|
|
37311
|
+
}
|
|
37312
|
+
if (u0 >= 0) {
|
|
37313
|
+
this.applyVector2(u0, this.source_textureCoords, geoData.uv_arr);
|
|
37314
|
+
} else {
|
|
37315
|
+
geoData.uv_arr.push(0, 0);
|
|
37316
|
+
}
|
|
37148
37317
|
geoData.indeice_arr[index] = index++;
|
|
37149
37318
|
this.applyVector3(f2, this.source_vertices, geoData.vertex_arr);
|
|
37150
|
-
|
|
37151
|
-
|
|
37319
|
+
if (n2 >= 0) {
|
|
37320
|
+
this.applyVector3(n2, this.source_normals, geoData.normal_arr);
|
|
37321
|
+
} else if (faceNormal2) {
|
|
37322
|
+
geoData.normal_arr.push(faceNormal2[0], faceNormal2[1], faceNormal2[2]);
|
|
37323
|
+
} else {
|
|
37324
|
+
geoData.normal_arr.push(0, 0, 0);
|
|
37325
|
+
}
|
|
37326
|
+
if (u2 >= 0) {
|
|
37327
|
+
this.applyVector2(u2, this.source_textureCoords, geoData.uv_arr);
|
|
37328
|
+
} else {
|
|
37329
|
+
geoData.uv_arr.push(0, 0);
|
|
37330
|
+
}
|
|
37152
37331
|
geoData.indeice_arr[index] = index++;
|
|
37153
37332
|
this.applyVector3(f3, this.source_vertices, geoData.vertex_arr);
|
|
37154
|
-
|
|
37155
|
-
|
|
37333
|
+
if (n3 >= 0) {
|
|
37334
|
+
this.applyVector3(n3, this.source_normals, geoData.normal_arr);
|
|
37335
|
+
} else if (faceNormal2) {
|
|
37336
|
+
geoData.normal_arr.push(faceNormal2[0], faceNormal2[1], faceNormal2[2]);
|
|
37337
|
+
} else {
|
|
37338
|
+
geoData.normal_arr.push(0, 0, 0);
|
|
37339
|
+
}
|
|
37340
|
+
if (u3 >= 0) {
|
|
37341
|
+
this.applyVector2(u3, this.source_textureCoords, geoData.uv_arr);
|
|
37342
|
+
} else {
|
|
37343
|
+
geoData.uv_arr.push(0, 0);
|
|
37344
|
+
}
|
|
37156
37345
|
geoData.indeice_arr[index] = index++;
|
|
37157
37346
|
}
|
|
37158
37347
|
}
|
|
@@ -37184,10 +37373,17 @@ else if (typeof exports === 'object')
|
|
|
37184
37373
|
topology: 0
|
|
37185
37374
|
});
|
|
37186
37375
|
let mat = new LitMaterial();
|
|
37187
|
-
|
|
37188
|
-
|
|
37189
|
-
|
|
37190
|
-
|
|
37376
|
+
const matName = geoData.source_mat;
|
|
37377
|
+
const matData = matName ? this.matLibs[matName] : void 0;
|
|
37378
|
+
if (matData && matData.map_Kd) {
|
|
37379
|
+
const texturePath = StringUtil.normalizePath(
|
|
37380
|
+
this.baseUrl + matData.map_Kd
|
|
37381
|
+
);
|
|
37382
|
+
const texture = Engine3D.res.getTexture(texturePath);
|
|
37383
|
+
if (texture) {
|
|
37384
|
+
mat.baseMap = texture;
|
|
37385
|
+
}
|
|
37386
|
+
}
|
|
37191
37387
|
let obj = new exports.Object3D();
|
|
37192
37388
|
let mr = obj.addComponent(exports.MeshRenderer);
|
|
37193
37389
|
mr.geometry = geo;
|
|
@@ -41064,7 +41260,7 @@ else if (typeof exports === 'object')
|
|
|
41064
41260
|
}
|
|
41065
41261
|
}
|
|
41066
41262
|
|
|
41067
|
-
const version = "1.0.
|
|
41263
|
+
const version = "1.0.20";
|
|
41068
41264
|
|
|
41069
41265
|
class Engine3D {
|
|
41070
41266
|
/**
|
package/dist/types/index.d.ts
CHANGED
|
@@ -381,9 +381,6 @@ export * from "./loader/LoaderManager";
|
|
|
381
381
|
export * from "./loader/parser/3dgs/GaussianSplatAsset";
|
|
382
382
|
export * from "./loader/parser/3dgs/GaussianSplatParser";
|
|
383
383
|
export * from "./loader/parser/3dgs/loaders/FormatDetector";
|
|
384
|
-
export * from "./loader/parser/3dgs/loaders/ply/PlyLoader";
|
|
385
|
-
export * from "./loader/parser/3dgs/loaders/ply/PlyTypes";
|
|
386
|
-
export * from "./loader/parser/3dgs/loaders/ply/PlyUtils";
|
|
387
384
|
export * from "./loader/parser/AtlasParser";
|
|
388
385
|
export * from "./loader/parser/B3DMParser";
|
|
389
386
|
export * from "./loader/parser/FontParser";
|
|
@@ -429,6 +426,9 @@ export * from "./loader/parser/kmz/dataDef/global";
|
|
|
429
426
|
export * from "./loader/parser/kmz/dataDef/point";
|
|
430
427
|
export * from "./loader/parser/kmz/dataDef/template";
|
|
431
428
|
export * from "./loader/parser/kmz/dataDef/wayline";
|
|
429
|
+
export * from "./loader/parser/ply/PlyLoader";
|
|
430
|
+
export * from "./loader/parser/ply/PlyTypes";
|
|
431
|
+
export * from "./loader/parser/ply/PlyUtils";
|
|
432
432
|
export * from "./loader/parser/prefab/PrefabAvatarParser";
|
|
433
433
|
export * from "./loader/parser/prefab/PrefabMaterialParser";
|
|
434
434
|
export * from "./loader/parser/prefab/PrefabMeshParser";
|
|
@@ -47,6 +47,8 @@ export declare class OBJParser extends ParserBase {
|
|
|
47
47
|
[name: string]: GeometryData;
|
|
48
48
|
};
|
|
49
49
|
private activeGeo;
|
|
50
|
+
private currentObjectName;
|
|
51
|
+
private currentMaterialName;
|
|
50
52
|
facesMaterialsIndex: {
|
|
51
53
|
materialName: string;
|
|
52
54
|
materialStartIndex: number;
|
|
@@ -57,8 +59,28 @@ export declare class OBJParser extends ParserBase {
|
|
|
57
59
|
private applyVector2;
|
|
58
60
|
private applyVector3;
|
|
59
61
|
private applyVector4;
|
|
62
|
+
/**
|
|
63
|
+
* Parse UV index with support for negative indices (OBJ format)
|
|
64
|
+
* Similar to Three.js parseUVIndex method
|
|
65
|
+
*/
|
|
66
|
+
private parseUVIndex;
|
|
67
|
+
/**
|
|
68
|
+
* Parse vertex index with support for negative indices (OBJ format)
|
|
69
|
+
*/
|
|
70
|
+
private parseVertexIndex;
|
|
71
|
+
/**
|
|
72
|
+
* Parse normal index with support for negative indices (OBJ format)
|
|
73
|
+
*/
|
|
74
|
+
private parseNormalIndex;
|
|
75
|
+
/**
|
|
76
|
+
* Calculate face normal from three vertices using cross product
|
|
77
|
+
* Similar to Three.js addFaceNormal method
|
|
78
|
+
*/
|
|
79
|
+
private calculateFaceNormal;
|
|
60
80
|
private loadMTL;
|
|
61
81
|
private load_textures;
|
|
82
|
+
private getGeometryKey;
|
|
83
|
+
private ensureActiveGeo;
|
|
62
84
|
private parserLine;
|
|
63
85
|
private parserOBJ;
|
|
64
86
|
private parser_mesh;
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|