|
@@ -1298,11 +1298,16 @@
|
|
url = [];
|
|
url = [];
|
|
|
|
|
|
for (var i = 0, l = image.length; i < l; i++) {
|
|
for (var i = 0, l = image.length; i < l; i++) {
|
|
- url.push(ImageUtils.getDataURL(image[i]));
|
|
|
|
|
|
+ // check cube texture with data textures
|
|
|
|
+ if (image[i].isDataTexture) {
|
|
|
|
+ url.push(serializeImage(image[i].image));
|
|
|
|
+ } else {
|
|
|
|
+ url.push(serializeImage(image[i]));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
// process single image
|
|
// process single image
|
|
- url = ImageUtils.getDataURL(image);
|
|
|
|
|
|
+ url = serializeImage(image);
|
|
}
|
|
}
|
|
|
|
|
|
meta.images[image.uuid] = {
|
|
meta.images[image.uuid] = {
|
|
@@ -1384,6 +1389,26 @@
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ function serializeImage(image) {
|
|
|
|
+ if (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement || typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) {
|
|
|
|
+ // default images
|
|
|
|
+ return ImageUtils.getDataURL(image);
|
|
|
|
+ } else {
|
|
|
|
+ if (image.data) {
|
|
|
|
+ // images of DataTexture
|
|
|
|
+ return {
|
|
|
|
+ data: Array.prototype.slice.call(image.data),
|
|
|
|
+ width: image.width,
|
|
|
|
+ height: image.height,
|
|
|
|
+ type: image.data.constructor.name
|
|
|
|
+ };
|
|
|
|
+ } else {
|
|
|
|
+ console.warn('THREE.Texture: Unable to serialize Texture.');
|
|
|
|
+ return {};
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
var Vector4 = /*#__PURE__*/function () {
|
|
var Vector4 = /*#__PURE__*/function () {
|
|
function Vector4(x, y, z, w) {
|
|
function Vector4(x, y, z, w) {
|
|
if (x === void 0) {
|
|
if (x === void 0) {
|
|
@@ -7658,6 +7683,23 @@
|
|
return max;
|
|
return max;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ var TYPED_ARRAYS = {
|
|
|
|
+ Int8Array: Int8Array,
|
|
|
|
+ Uint8Array: Uint8Array,
|
|
|
|
+ // Workaround for IE11 pre KB2929437. See #11440
|
|
|
|
+ Uint8ClampedArray: typeof Uint8ClampedArray !== 'undefined' ? Uint8ClampedArray : Uint8Array,
|
|
|
|
+ Int16Array: Int16Array,
|
|
|
|
+ Uint16Array: Uint16Array,
|
|
|
|
+ Int32Array: Int32Array,
|
|
|
|
+ Uint32Array: Uint32Array,
|
|
|
|
+ Float32Array: Float32Array,
|
|
|
|
+ Float64Array: Float64Array
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ function getTypedArray(type, buffer) {
|
|
|
|
+ return new TYPED_ARRAYS[type](buffer);
|
|
|
|
+ }
|
|
|
|
+
|
|
var _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id
|
|
var _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id
|
|
|
|
|
|
var _m1$2 = new Matrix4();
|
|
var _m1$2 = new Matrix4();
|
|
@@ -29647,7 +29689,7 @@
|
|
var interleavedBuffers = json.interleavedBuffers;
|
|
var interleavedBuffers = json.interleavedBuffers;
|
|
var interleavedBuffer = interleavedBuffers[uuid];
|
|
var interleavedBuffer = interleavedBuffers[uuid];
|
|
var buffer = getArrayBuffer(json, interleavedBuffer.buffer);
|
|
var buffer = getArrayBuffer(json, interleavedBuffer.buffer);
|
|
- var array = new TYPED_ARRAYS[interleavedBuffer.type](buffer);
|
|
|
|
|
|
+ var array = getTypedArray(interleavedBuffer.type, buffer);
|
|
var ib = new InterleavedBuffer(array, interleavedBuffer.stride);
|
|
var ib = new InterleavedBuffer(array, interleavedBuffer.stride);
|
|
ib.uuid = interleavedBuffer.uuid;
|
|
ib.uuid = interleavedBuffer.uuid;
|
|
interleavedBufferMap[uuid] = ib;
|
|
interleavedBufferMap[uuid] = ib;
|
|
@@ -29667,7 +29709,7 @@
|
|
var index = json.data.index;
|
|
var index = json.data.index;
|
|
|
|
|
|
if (index !== undefined) {
|
|
if (index !== undefined) {
|
|
- var typedArray = new TYPED_ARRAYS[index.type](index.array);
|
|
|
|
|
|
+ var typedArray = getTypedArray(index.type, index.array);
|
|
geometry.setIndex(new BufferAttribute(typedArray, 1));
|
|
geometry.setIndex(new BufferAttribute(typedArray, 1));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -29681,7 +29723,7 @@
|
|
var interleavedBuffer = getInterleavedBuffer(json.data, attribute.data);
|
|
var interleavedBuffer = getInterleavedBuffer(json.data, attribute.data);
|
|
bufferAttribute = new InterleavedBufferAttribute(interleavedBuffer, attribute.itemSize, attribute.offset, attribute.normalized);
|
|
bufferAttribute = new InterleavedBufferAttribute(interleavedBuffer, attribute.itemSize, attribute.offset, attribute.normalized);
|
|
} else {
|
|
} else {
|
|
- var _typedArray = new TYPED_ARRAYS[attribute.type](attribute.array);
|
|
|
|
|
|
+ var _typedArray = getTypedArray(attribute.type, attribute.array);
|
|
|
|
|
|
var bufferAttributeConstr = attribute.isInstancedBufferAttribute ? InstancedBufferAttribute : BufferAttribute;
|
|
var bufferAttributeConstr = attribute.isInstancedBufferAttribute ? InstancedBufferAttribute : BufferAttribute;
|
|
bufferAttribute = new bufferAttributeConstr(_typedArray, attribute.itemSize, attribute.normalized);
|
|
bufferAttribute = new bufferAttributeConstr(_typedArray, attribute.itemSize, attribute.normalized);
|
|
@@ -29708,7 +29750,7 @@
|
|
|
|
|
|
_bufferAttribute = new InterleavedBufferAttribute(_interleavedBuffer, _attribute.itemSize, _attribute.offset, _attribute.normalized);
|
|
_bufferAttribute = new InterleavedBufferAttribute(_interleavedBuffer, _attribute.itemSize, _attribute.offset, _attribute.normalized);
|
|
} else {
|
|
} else {
|
|
- var _typedArray2 = new TYPED_ARRAYS[_attribute.type](_attribute.array);
|
|
|
|
|
|
+ var _typedArray2 = getTypedArray(_attribute.type, _attribute.array);
|
|
|
|
|
|
_bufferAttribute = new BufferAttribute(_typedArray2, _attribute.itemSize, _attribute.normalized);
|
|
_bufferAttribute = new BufferAttribute(_typedArray2, _attribute.itemSize, _attribute.normalized);
|
|
}
|
|
}
|
|
@@ -29753,18 +29795,6 @@
|
|
return geometry;
|
|
return geometry;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- var TYPED_ARRAYS = {
|
|
|
|
- Int8Array: Int8Array,
|
|
|
|
- Uint8Array: Uint8Array,
|
|
|
|
- // Workaround for IE11 pre KB2929437. See #11440
|
|
|
|
- Uint8ClampedArray: typeof Uint8ClampedArray !== 'undefined' ? Uint8ClampedArray : Uint8Array,
|
|
|
|
- Int16Array: Int16Array,
|
|
|
|
- Uint16Array: Uint16Array,
|
|
|
|
- Int32Array: Int32Array,
|
|
|
|
- Uint32Array: Uint32Array,
|
|
|
|
- Float32Array: Float32Array,
|
|
|
|
- Float64Array: Float64Array
|
|
|
|
- };
|
|
|
|
|
|
|
|
var ObjectLoader = /*#__PURE__*/function (_Loader) {
|
|
var ObjectLoader = /*#__PURE__*/function (_Loader) {
|
|
_inheritsLoose(ObjectLoader, _Loader);
|
|
_inheritsLoose(ObjectLoader, _Loader);
|
|
@@ -30068,6 +30098,24 @@
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function deserializeImage(image) {
|
|
|
|
+ if (typeof image === 'string') {
|
|
|
|
+ var url = image;
|
|
|
|
+ var path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(url) ? url : scope.resourcePath + url;
|
|
|
|
+ return loadImage(path);
|
|
|
|
+ } else {
|
|
|
|
+ if (image.data) {
|
|
|
|
+ return {
|
|
|
|
+ data: getTypedArray(image.type, image.data),
|
|
|
|
+ width: image.width,
|
|
|
|
+ height: image.height
|
|
|
|
+ };
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if (json !== undefined && json.length > 0) {
|
|
if (json !== undefined && json.length > 0) {
|
|
var manager = new LoadingManager(onLoad);
|
|
var manager = new LoadingManager(onLoad);
|
|
loader = new ImageLoader(manager);
|
|
loader = new ImageLoader(manager);
|
|
@@ -30083,14 +30131,24 @@
|
|
|
|
|
|
for (var j = 0, jl = url.length; j < jl; j++) {
|
|
for (var j = 0, jl = url.length; j < jl; j++) {
|
|
var currentUrl = url[j];
|
|
var currentUrl = url[j];
|
|
- var path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(currentUrl) ? currentUrl : scope.resourcePath + currentUrl;
|
|
|
|
- images[image.uuid].push(loadImage(path));
|
|
|
|
|
|
+ var deserializedImage = deserializeImage(currentUrl);
|
|
|
|
+
|
|
|
|
+ if (deserializedImage !== null) {
|
|
|
|
+ if (deserializedImage instanceof HTMLImageElement) {
|
|
|
|
+ images[image.uuid].push(deserializedImage);
|
|
|
|
+ } else {
|
|
|
|
+ // special case: handle array of data textures for cube textures
|
|
|
|
+ images[image.uuid].push(new DataTexture(deserializedImage.data, deserializedImage.width, deserializedImage.height));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
// load single image
|
|
// load single image
|
|
- var _path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(image.url) ? image.url : scope.resourcePath + image.url;
|
|
|
|
|
|
+ var _deserializedImage = deserializeImage(image.url);
|
|
|
|
|
|
- images[image.uuid] = loadImage(_path);
|
|
|
|
|
|
+ if (_deserializedImage !== null) {
|
|
|
|
+ images[image.uuid] = _deserializedImage;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -30120,14 +30178,21 @@
|
|
}
|
|
}
|
|
|
|
|
|
var texture = void 0;
|
|
var texture = void 0;
|
|
|
|
+ var image = images[data.image];
|
|
|
|
|
|
- if (Array.isArray(images[data.image])) {
|
|
|
|
- texture = new CubeTexture(images[data.image]);
|
|
|
|
|
|
+ if (Array.isArray(image)) {
|
|
|
|
+ texture = new CubeTexture(image);
|
|
|
|
+ if (image.length === 6) texture.needsUpdate = true;
|
|
} else {
|
|
} else {
|
|
- texture = new Texture(images[data.image]);
|
|
|
|
|
|
+ if (image && image.data) {
|
|
|
|
+ texture = new DataTexture(image.data, image.width, image.height);
|
|
|
|
+ } else {
|
|
|
|
+ texture = new Texture(image);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (image) texture.needsUpdate = true; // textures can have undefined image data
|
|
}
|
|
}
|
|
|
|
|
|
- texture.needsUpdate = true;
|
|
|
|
texture.uuid = data.uuid;
|
|
texture.uuid = data.uuid;
|
|
if (data.name !== undefined) texture.name = data.name;
|
|
if (data.name !== undefined) texture.name = data.name;
|
|
if (data.mapping !== undefined) texture.mapping = parseConstant(data.mapping, TEXTURE_MAPPING);
|
|
if (data.mapping !== undefined) texture.mapping = parseConstant(data.mapping, TEXTURE_MAPPING);
|