Compare commits
No commits in common. "4503f502ae6661ca1a0b2878a3d0eaca61a4af2b" and "62775a5939dc99da56a391427ecae6dafd79a96c" have entirely different histories.
4503f502ae
...
62775a5939
@ -8,7 +8,7 @@ EditorBuildSettings:
|
|||||||
- enabled: 1
|
- enabled: 1
|
||||||
path: Assets/Scenes/Main.unity
|
path: Assets/Scenes/Main.unity
|
||||||
guid: d1c3109bdb54ad54c8a2b2838528e640
|
guid: d1c3109bdb54ad54c8a2b2838528e640
|
||||||
- enabled: 0
|
- enabled: 1
|
||||||
path: Assets/Scenes/Test.unity
|
path: Assets/Scenes/Test.unity
|
||||||
guid: 0b73b822f37c6584daec4f5aa1eb17db
|
guid: 0b73b822f37c6584daec4f5aa1eb17db
|
||||||
m_configObjects: {}
|
m_configObjects: {}
|
||||||
|
|||||||
@ -819,7 +819,7 @@ PlayerSettings:
|
|||||||
webGLDebugSymbols: 0
|
webGLDebugSymbols: 0
|
||||||
webGLEmscriptenArgs:
|
webGLEmscriptenArgs:
|
||||||
webGLModulesDirectory:
|
webGLModulesDirectory:
|
||||||
webGLTemplate: APPLICATION:Default
|
webGLTemplate: PROJECT:MyIndex
|
||||||
webGLAnalyzeBuildSize: 0
|
webGLAnalyzeBuildSize: 0
|
||||||
webGLUseEmbeddedResources: 0
|
webGLUseEmbeddedResources: 0
|
||||||
webGLCompressionFormat: 1
|
webGLCompressionFormat: 1
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 127 KiB |
|
Before Width: | Height: | Size: 113 KiB |
|
Before Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 101 KiB |
|
Before Width: | Height: | Size: 8.3 MiB |
|
Before Width: | Height: | Size: 32 KiB |
@ -1,113 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Module>
|
|
||||||
<Scene>Test</Scene>
|
|
||||||
<Type>All</Type>
|
|
||||||
<Name>3D解刨</Name>
|
|
||||||
|
|
||||||
|
|
||||||
<FSM name="状态机1">
|
|
||||||
<State name="初始状态">
|
|
||||||
<Enter>
|
|
||||||
<Action type="Parallel">
|
|
||||||
|
|
||||||
<Action type="UIShow" value="UI3DObjSelect"></Action>
|
|
||||||
|
|
||||||
</Action>
|
|
||||||
</Enter>
|
|
||||||
</State>
|
|
||||||
<!--<Transision from="初始状态" to="状态2">
|
|
||||||
<Condition type="ObjClick" value="Cube (1)"></Condition>
|
|
||||||
</Transision>-->
|
|
||||||
</FSM>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Body3D>
|
|
||||||
<Body name="头颈" icon="" path="Ren/Tou" >
|
|
||||||
<Body name="骨骼系统" path="Ren/Tou/GuGe" isShow="false">
|
|
||||||
<Body name="肋骨" path="Ren/Tou/GuGe/LeiGu">
|
|
||||||
<Body name="左肋" path="Ren/Tou/GuGe/LeiGu/ZuoLei">
|
|
||||||
<Body name="左一" path="Ren/Tou/GuGe/LeiGu/ZuoLei/1" tip="左一肋骨描述">
|
|
||||||
<ObjectToggle>
|
|
||||||
<Color isOn="0,255,255" isOff="255,255,255"></Color>
|
|
||||||
</ObjectToggle>
|
|
||||||
</Body>
|
|
||||||
<Body name="左二" path="Ren/Tou/GuGe/LeiGu/ZuoLei/2" tip="左二肋骨描述">
|
|
||||||
<ObjectToggle>
|
|
||||||
<Color isOn="0,255,255" isOff="255,255,255"></Color>
|
|
||||||
</ObjectToggle>
|
|
||||||
</Body>
|
|
||||||
</Body>
|
|
||||||
<Body name="右肋" path="Ren/Tou/GuGe/LeiGu/YouLei">
|
|
||||||
<Body name="右一" path="Ren/Tou/GuGe/LeiGu/YouLei/1" tip="7右一肋骨描述">
|
|
||||||
<ObjectToggle>
|
|
||||||
<Color isOn="0,255,255" isOff="255,255,255"></Color>
|
|
||||||
</ObjectToggle>
|
|
||||||
</Body>
|
|
||||||
<Body name="右二" path="Ren/Tou/GuGe/LeiGu/YouLei/2" tip="右二肋骨描述">
|
|
||||||
<ObjectToggle>
|
|
||||||
<Color isOn="0,255,255" isOff="255,255,255"></Color>
|
|
||||||
</ObjectToggle>
|
|
||||||
</Body>
|
|
||||||
</Body>
|
|
||||||
</Body>
|
|
||||||
</Body>
|
|
||||||
<Body name="皮肤系统" path="Ren/Tou/PiFu" isShow="false">
|
|
||||||
<Body name="肋骨" path="Ren/Tou/PiFu/LeiGu">
|
|
||||||
<Body name="左肋" path="Ren/Tou/PiFu/LeiGu/ZuoLei">
|
|
||||||
<Body name="左一" path="Ren/Tou/PiFu/LeiGu/ZuoLei/1"></Body>
|
|
||||||
<Body name="左二" path="Ren/Tou/PiFu/LeiGu/ZuoLei/2"></Body>
|
|
||||||
</Body>
|
|
||||||
<Body name="右肋" path="Ren/Tou/PiFu/LeiGu/YouLei">
|
|
||||||
<Body name="右一" path="Ren/Tou/PiFu/LeiGu/YouLei/1"></Body>
|
|
||||||
<Body name="右二" path="Ren/Tou/PiFu/LeiGu/YouLei/2"></Body>
|
|
||||||
</Body>
|
|
||||||
</Body>
|
|
||||||
</Body>
|
|
||||||
<Body name="肌肉" isBodyList="true" path="Ren/Tou/JiRou">
|
|
||||||
<Body name="111" path="Ren/Tou/JiRou/1">
|
|
||||||
<ObjectToggle>
|
|
||||||
<Color></Color>
|
|
||||||
</ObjectToggle>
|
|
||||||
</Body>
|
|
||||||
<Body name="222" path="Ren/Tou/JiRou/2">
|
|
||||||
<ObjectToggle>
|
|
||||||
<Color></Color>
|
|
||||||
</ObjectToggle>
|
|
||||||
</Body>
|
|
||||||
<Body name="333" path="Ren/Tou/JiRou/3">
|
|
||||||
<ObjectToggle>
|
|
||||||
<Color></Color>
|
|
||||||
</ObjectToggle>
|
|
||||||
</Body>
|
|
||||||
</Body>
|
|
||||||
<!--<Body name="神经" isBodyList="true">
|
|
||||||
<Body name="aaa" path="Ren/Tou/ShenJing/1">
|
|
||||||
<ObjectToggle>
|
|
||||||
<Color></Color>
|
|
||||||
</ObjectToggle>
|
|
||||||
</Body>
|
|
||||||
<Body name="bbb" path="Ren/Tou/ShenJing/2">
|
|
||||||
<ObjectToggle>
|
|
||||||
<Color></Color>
|
|
||||||
</ObjectToggle>
|
|
||||||
</Body>
|
|
||||||
<Body name="ccc" path="Ren/Tou/ShenJing/3">
|
|
||||||
<ObjectToggle>
|
|
||||||
<Color></Color>
|
|
||||||
</ObjectToggle>
|
|
||||||
</Body>
|
|
||||||
</Body>-->
|
|
||||||
</Body>
|
|
||||||
<Body name="肩膀" icon="" path="Ren/JianBang" >
|
|
||||||
<Body name="肩膀系统1" path="Ren/JianBang/Cube">
|
|
||||||
<Body name="肋骨" path="Ren/JianBang/Cube/Cube (1)">
|
|
||||||
<Body name="左肋" path="Ren/JianBang/Cube/Cube (1)/Cube (2)">
|
|
||||||
<Body name="左一" path="Ren/JianBang/Cube/Cube (1)/Cube (2)/Cube (3)"></Body>
|
|
||||||
<Body name="左二" path="Ren/JianBang/Cube/Cube (1)/Cube (2)/Sphere"></Body>
|
|
||||||
</Body>
|
|
||||||
</Body>
|
|
||||||
</Body>
|
|
||||||
</Body>
|
|
||||||
</Body3D>
|
|
||||||
</Module>
|
|
||||||
@ -1 +0,0 @@
|
|||||||
ILBJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>05<EFBFBD>
<0A><>l<EFBFBD><6C>F<03>)<29>#<1E><>BȲ<42><17>Uv<55>}]<5D>u.<2E><>\G<>
|
|
||||||
@ -1,188 +0,0 @@
|
|||||||
/* FileSaver.js
|
|
||||||
* A saveAs() FileSaver implementation.
|
|
||||||
* 1.3.2
|
|
||||||
* 2016-06-16 18:25:19
|
|
||||||
*
|
|
||||||
* By Eli Grey, http://eligrey.com
|
|
||||||
* License: MIT
|
|
||||||
* See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*global self */
|
|
||||||
/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
|
|
||||||
|
|
||||||
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
|
|
||||||
|
|
||||||
var saveAs = saveAs || (function(view) {
|
|
||||||
"use strict";
|
|
||||||
// IE <10 is explicitly unsupported
|
|
||||||
if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var
|
|
||||||
doc = view.document
|
|
||||||
// only get URL when necessary in case Blob.js hasn't overridden it yet
|
|
||||||
, get_URL = function() {
|
|
||||||
return view.URL || view.webkitURL || view;
|
|
||||||
}
|
|
||||||
, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
|
|
||||||
, can_use_save_link = "download" in save_link
|
|
||||||
, click = function(node) {
|
|
||||||
var event = new MouseEvent("click");
|
|
||||||
node.dispatchEvent(event);
|
|
||||||
}
|
|
||||||
, is_safari = /constructor/i.test(view.HTMLElement) || view.safari
|
|
||||||
, is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent)
|
|
||||||
, throw_outside = function(ex) {
|
|
||||||
(view.setImmediate || view.setTimeout)(function() {
|
|
||||||
throw ex;
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
, force_saveable_type = "application/octet-stream"
|
|
||||||
// the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to
|
|
||||||
, arbitrary_revoke_timeout = 1000 * 40 // in ms
|
|
||||||
, revoke = function(file) {
|
|
||||||
var revoker = function() {
|
|
||||||
if (typeof file === "string") { // file is an object URL
|
|
||||||
get_URL().revokeObjectURL(file);
|
|
||||||
} else { // file is a File
|
|
||||||
file.remove();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
setTimeout(revoker, arbitrary_revoke_timeout);
|
|
||||||
}
|
|
||||||
, dispatch = function(filesaver, event_types, event) {
|
|
||||||
event_types = [].concat(event_types);
|
|
||||||
var i = event_types.length;
|
|
||||||
while (i--) {
|
|
||||||
var listener = filesaver["on" + event_types[i]];
|
|
||||||
if (typeof listener === "function") {
|
|
||||||
try {
|
|
||||||
listener.call(filesaver, event || filesaver);
|
|
||||||
} catch (ex) {
|
|
||||||
throw_outside(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
, auto_bom = function(blob) {
|
|
||||||
// prepend BOM for UTF-8 XML and text/* types (including HTML)
|
|
||||||
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
|
|
||||||
if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
|
|
||||||
return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});
|
|
||||||
}
|
|
||||||
return blob;
|
|
||||||
}
|
|
||||||
, FileSaver = function(blob, name, no_auto_bom) {
|
|
||||||
if (!no_auto_bom) {
|
|
||||||
blob = auto_bom(blob);
|
|
||||||
}
|
|
||||||
// First try a.download, then web filesystem, then object URLs
|
|
||||||
var
|
|
||||||
filesaver = this
|
|
||||||
, type = blob.type
|
|
||||||
, force = type === force_saveable_type
|
|
||||||
, object_url
|
|
||||||
, dispatch_all = function() {
|
|
||||||
dispatch(filesaver, "writestart progress write writeend".split(" "));
|
|
||||||
}
|
|
||||||
// on any filesys errors revert to saving with object URLs
|
|
||||||
, fs_error = function() {
|
|
||||||
if ((is_chrome_ios || (force && is_safari)) && view.FileReader) {
|
|
||||||
// Safari doesn't allow downloading of blob urls
|
|
||||||
var reader = new FileReader();
|
|
||||||
reader.onloadend = function() {
|
|
||||||
var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');
|
|
||||||
var popup = view.open(url, '_blank');
|
|
||||||
if(!popup) view.location.href = url;
|
|
||||||
url=undefined; // release reference before dispatching
|
|
||||||
filesaver.readyState = filesaver.DONE;
|
|
||||||
dispatch_all();
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(blob);
|
|
||||||
filesaver.readyState = filesaver.INIT;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// don't create more object URLs than needed
|
|
||||||
if (!object_url) {
|
|
||||||
object_url = get_URL().createObjectURL(blob);
|
|
||||||
}
|
|
||||||
if (force) {
|
|
||||||
view.location.href = object_url;
|
|
||||||
} else {
|
|
||||||
var opened = view.open(object_url, "_blank");
|
|
||||||
if (!opened) {
|
|
||||||
// Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html
|
|
||||||
view.location.href = object_url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
filesaver.readyState = filesaver.DONE;
|
|
||||||
dispatch_all();
|
|
||||||
revoke(object_url);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
filesaver.readyState = filesaver.INIT;
|
|
||||||
|
|
||||||
if (can_use_save_link) {
|
|
||||||
object_url = get_URL().createObjectURL(blob);
|
|
||||||
setTimeout(function() {
|
|
||||||
save_link.href = object_url;
|
|
||||||
save_link.download = name;
|
|
||||||
click(save_link);
|
|
||||||
dispatch_all();
|
|
||||||
revoke(object_url);
|
|
||||||
filesaver.readyState = filesaver.DONE;
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fs_error();
|
|
||||||
}
|
|
||||||
, FS_proto = FileSaver.prototype
|
|
||||||
, saveAs = function(blob, name, no_auto_bom) {
|
|
||||||
return new FileSaver(blob, name || blob.name || "download", no_auto_bom);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
// IE 10+ (native saveAs)
|
|
||||||
if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
|
|
||||||
return function(blob, name, no_auto_bom) {
|
|
||||||
name = name || blob.name || "download";
|
|
||||||
|
|
||||||
if (!no_auto_bom) {
|
|
||||||
blob = auto_bom(blob);
|
|
||||||
}
|
|
||||||
return navigator.msSaveOrOpenBlob(blob, name);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
FS_proto.abort = function(){};
|
|
||||||
FS_proto.readyState = FS_proto.INIT = 0;
|
|
||||||
FS_proto.WRITING = 1;
|
|
||||||
FS_proto.DONE = 2;
|
|
||||||
|
|
||||||
FS_proto.error =
|
|
||||||
FS_proto.onwritestart =
|
|
||||||
FS_proto.onprogress =
|
|
||||||
FS_proto.onwrite =
|
|
||||||
FS_proto.onabort =
|
|
||||||
FS_proto.onerror =
|
|
||||||
FS_proto.onwriteend =
|
|
||||||
null;
|
|
||||||
|
|
||||||
return saveAs;
|
|
||||||
}(
|
|
||||||
typeof self !== "undefined" && self
|
|
||||||
|| typeof window !== "undefined" && window
|
|
||||||
|| this.content
|
|
||||||
));
|
|
||||||
// `self` is undefined in Firefox for Android content script context
|
|
||||||
// while `this` is nsIContentFrameMessageManager
|
|
||||||
// with an attribute `content` that corresponds to the window
|
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module.exports) {
|
|
||||||
module.exports.saveAs = saveAs;
|
|
||||||
} else if ((typeof define !== "undefined" && define !== null) && (define.amd !== null)) {
|
|
||||||
define("FileSaver.js", function() {
|
|
||||||
return saveAs;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -1,112 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
const DocUtils = require("./docUtils");
|
|
||||||
const extensionRegex = /[^.]+\.([^.]+)/;
|
|
||||||
|
|
||||||
const rels = {
|
|
||||||
getPrefix(fileType) {
|
|
||||||
return fileType === "docx" ? "word" : "ppt";
|
|
||||||
},
|
|
||||||
getFileTypeName(fileType) {
|
|
||||||
return fileType === "docx" ? "document" : "presentation";
|
|
||||||
},
|
|
||||||
getRelsFileName(fileName) {
|
|
||||||
return fileName.replace(/^.*?([a-zA-Z0-9]+)\.xml$/, "$1") + ".xml.rels";
|
|
||||||
},
|
|
||||||
getRelsFilePath(fileName, fileType) {
|
|
||||||
const relsFileName = rels.getRelsFileName(fileName);
|
|
||||||
const prefix = fileType === "pptx" ? "ppt/slides" : "word";
|
|
||||||
return `${prefix}/_rels/${relsFileName}`;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = class ImgManager {
|
|
||||||
constructor(zip, fileName, xmlDocuments, fileType) {
|
|
||||||
this.fileName = fileName;
|
|
||||||
this.prefix = rels.getPrefix(fileType);
|
|
||||||
this.zip = zip;
|
|
||||||
this.xmlDocuments = xmlDocuments;
|
|
||||||
this.fileTypeName = rels.getFileTypeName(fileType);
|
|
||||||
this.mediaPrefix = fileType === "pptx" ? "../media" : "media";
|
|
||||||
const relsFilePath = rels.getRelsFilePath(fileName, fileType);
|
|
||||||
this.relsDoc = xmlDocuments[relsFilePath] || this.createEmptyRelsDoc(xmlDocuments, relsFilePath);
|
|
||||||
}
|
|
||||||
createEmptyRelsDoc(xmlDocuments, relsFileName) {
|
|
||||||
const mainRels = this.prefix + "/_rels/" + (this.fileTypeName) + ".xml.rels";
|
|
||||||
const doc = xmlDocuments[mainRels];
|
|
||||||
if (!doc) {
|
|
||||||
const err = new Error("Could not copy from empty relsdoc");
|
|
||||||
err.properties = {
|
|
||||||
mainRels,
|
|
||||||
relsFileName,
|
|
||||||
files: Object.keys(this.zip.files),
|
|
||||||
};
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
const relsDoc = DocUtils.str2xml(DocUtils.xml2str(doc));
|
|
||||||
const relationships = relsDoc.getElementsByTagName("Relationships")[0];
|
|
||||||
const relationshipChilds = relationships.getElementsByTagName("Relationship");
|
|
||||||
for (let i = 0, l = relationshipChilds.length; i < l; i++) {
|
|
||||||
relationships.removeChild(relationshipChilds[i]);
|
|
||||||
}
|
|
||||||
xmlDocuments[relsFileName] = relsDoc;
|
|
||||||
return relsDoc;
|
|
||||||
}
|
|
||||||
loadImageRels() {
|
|
||||||
const iterable = this.relsDoc.getElementsByTagName("Relationship");
|
|
||||||
return Array.prototype.reduce.call(iterable, function (max, relationship) {
|
|
||||||
const id = relationship.getAttribute("Id");
|
|
||||||
if (/^rId[0-9]+$/.test(id)) {
|
|
||||||
return Math.max(max, parseInt(id.substr(3), 10));
|
|
||||||
}
|
|
||||||
return max;
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
// Add an extension type in the [Content_Types.xml], is used if for example you want word to be able to read png files (for every extension you add you need a contentType)
|
|
||||||
addExtensionRels(contentType, extension) {
|
|
||||||
const contentTypeDoc = this.xmlDocuments["[Content_Types].xml"];
|
|
||||||
const defaultTags = contentTypeDoc.getElementsByTagName("Default");
|
|
||||||
const extensionRegistered = Array.prototype.some.call(defaultTags, function (tag) {
|
|
||||||
return tag.getAttribute("Extension") === extension;
|
|
||||||
});
|
|
||||||
if (extensionRegistered) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const types = contentTypeDoc.getElementsByTagName("Types")[0];
|
|
||||||
const newTag = contentTypeDoc.createElement("Default");
|
|
||||||
newTag.namespaceURI = null;
|
|
||||||
newTag.setAttribute("ContentType", contentType);
|
|
||||||
newTag.setAttribute("Extension", extension);
|
|
||||||
types.appendChild(newTag);
|
|
||||||
}
|
|
||||||
// Add an image and returns it's Rid
|
|
||||||
addImageRels(imageName, imageData, i) {
|
|
||||||
if (i == null) {
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
const realImageName = i === 0 ? imageName : imageName + `(${i})`;
|
|
||||||
const imagePath = `${this.prefix}/media/${realImageName}`;
|
|
||||||
if (this.zip.files[imagePath] != null) {
|
|
||||||
return this.addImageRels(imageName, imageData, i + 1);
|
|
||||||
}
|
|
||||||
const image = {
|
|
||||||
name: imagePath,
|
|
||||||
data: imageData,
|
|
||||||
options: {
|
|
||||||
binary: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
this.zip.file(image.name, image.data, image.options);
|
|
||||||
const extension = realImageName.replace(extensionRegex, "$1");
|
|
||||||
this.addExtensionRels(`image/${extension}`, extension);
|
|
||||||
const relationships = this.relsDoc.getElementsByTagName("Relationships")[0];
|
|
||||||
const newTag = this.relsDoc.createElement("Relationship");
|
|
||||||
newTag.namespaceURI = null;
|
|
||||||
const maxRid = this.loadImageRels() + 1;
|
|
||||||
newTag.setAttribute("Id", `rId${maxRid}`);
|
|
||||||
newTag.setAttribute("Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image");
|
|
||||||
newTag.setAttribute("Target", `${this.mediaPrefix}/${realImageName}`);
|
|
||||||
relationships.appendChild(newTag);
|
|
||||||
return maxRid;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@ -1,176 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
const templates = require("./templates");
|
|
||||||
const DocUtils = require("docxtemplater").DocUtils;
|
|
||||||
const DOMParser = require("xmldom").DOMParser;
|
|
||||||
|
|
||||||
function isNaN(number) {
|
|
||||||
return !(number === number);
|
|
||||||
}
|
|
||||||
|
|
||||||
const ImgManager = require("./imgManager");
|
|
||||||
const moduleName = "open-xml-templating/docxtemplater-image-module";
|
|
||||||
|
|
||||||
function getInnerDocx({part}) {
|
|
||||||
return part;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getInnerPptx({part, left, right, postparsed}) {
|
|
||||||
const xmlString = postparsed.slice(left + 1, right).reduce(function (concat, item) {
|
|
||||||
return concat + item.value;
|
|
||||||
}, "");
|
|
||||||
const xmlDoc = new DOMParser().parseFromString("<xml>" + xmlString + "</xml>");
|
|
||||||
part.offset = {x: 0, y: 0};
|
|
||||||
part.ext = {cx: 0, cy: 0};
|
|
||||||
const offset = xmlDoc.getElementsByTagName("a:off");
|
|
||||||
const ext = xmlDoc.getElementsByTagName("a:ext");
|
|
||||||
if (ext.length > 0) {
|
|
||||||
part.ext.cx = parseInt(ext[ext.length - 1].getAttribute("cx"), 10);
|
|
||||||
part.ext.cy = parseInt(ext[ext.length - 1].getAttribute("cy"), 10);
|
|
||||||
}
|
|
||||||
if (offset.length > 0) {
|
|
||||||
part.offset.x = parseInt(offset[offset.length - 1].getAttribute("x"), 10);
|
|
||||||
part.offset.y = parseInt(offset[offset.length - 1].getAttribute("y"), 10);
|
|
||||||
}
|
|
||||||
return part;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ImageModule {
|
|
||||||
constructor(options) {
|
|
||||||
this.name = "ImageModule";
|
|
||||||
this.options = options || {};
|
|
||||||
this.imgManagers = {};
|
|
||||||
if (this.options.centered == null) { this.options.centered = false; }
|
|
||||||
if (this.options.getImage == null) { throw new Error("You should pass getImage"); }
|
|
||||||
if (this.options.getSize == null) { throw new Error("You should pass getSize"); }
|
|
||||||
this.imageNumber = 1;
|
|
||||||
}
|
|
||||||
optionsTransformer(options, docxtemplater) {
|
|
||||||
const relsFiles = docxtemplater.zip.file(/\.xml\.rels/)
|
|
||||||
.concat(docxtemplater.zip.file(/\[Content_Types\].xml/))
|
|
||||||
.map((file) => file.name);
|
|
||||||
this.fileTypeConfig = docxtemplater.fileTypeConfig;
|
|
||||||
this.fileType = docxtemplater.fileType;
|
|
||||||
this.zip = docxtemplater.zip;
|
|
||||||
options.xmlFileNames = options.xmlFileNames.concat(relsFiles);
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
set(options) {
|
|
||||||
if (options.zip) {
|
|
||||||
this.zip = options.zip;
|
|
||||||
}
|
|
||||||
if (options.xmlDocuments) {
|
|
||||||
this.xmlDocuments = options.xmlDocuments;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parse(placeHolderContent) {
|
|
||||||
const module = moduleName;
|
|
||||||
const type = "placeholder";
|
|
||||||
if (this.options.setParser) {
|
|
||||||
return this.options.setParser(placeHolderContent);
|
|
||||||
}
|
|
||||||
if (placeHolderContent.substring(0, 2) === "%%") {
|
|
||||||
return {type, value: placeHolderContent.substr(2), module, centered: true};
|
|
||||||
}
|
|
||||||
if (placeHolderContent.substring(0, 1) === "%") {
|
|
||||||
return {type, value: placeHolderContent.substr(1), module, centered: false};
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
postparse(parsed) {
|
|
||||||
let expandTo;
|
|
||||||
let getInner;
|
|
||||||
if (this.fileType === "pptx") {
|
|
||||||
expandTo = "p:sp";
|
|
||||||
getInner = getInnerPptx;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
expandTo = this.options.centered ? "w:p" : "w:t";
|
|
||||||
getInner = getInnerDocx;
|
|
||||||
}
|
|
||||||
return DocUtils.traits.expandToOne(parsed, {moduleName, getInner, expandTo});
|
|
||||||
}
|
|
||||||
render(part, options) {
|
|
||||||
if (!part.type === "placeholder" || part.module !== moduleName) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const tagValue = options.scopeManager.getValue(part.value, {
|
|
||||||
part: part,
|
|
||||||
});
|
|
||||||
if (!tagValue) {
|
|
||||||
return {value: this.fileTypeConfig.tagTextXml};
|
|
||||||
}
|
|
||||||
else if (typeof tagValue === "object") {
|
|
||||||
return this.getRenderedPart(part, tagValue.rId, tagValue.sizePixel);
|
|
||||||
}
|
|
||||||
const imgManager = new ImgManager(this.zip, options.filePath, this.xmlDocuments, this.fileType);
|
|
||||||
const imgBuffer = this.options.getImage(tagValue, part.value);
|
|
||||||
const rId = imgManager.addImageRels(this.getNextImageName(), imgBuffer);
|
|
||||||
const sizePixel = this.options.getSize(imgBuffer, tagValue, part.value);
|
|
||||||
return this.getRenderedPart(part, rId, sizePixel);
|
|
||||||
}
|
|
||||||
resolve(part, options) {
|
|
||||||
const imgManager = new ImgManager(this.zip, options.filePath, this.xmlDocuments, this.fileType);
|
|
||||||
if (!part.type === "placeholder" || part.module !== moduleName) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const value = options.scopeManager.getValue(part.value, {
|
|
||||||
part: part,
|
|
||||||
});
|
|
||||||
if (!value) {
|
|
||||||
return {value: this.fileTypeConfig.tagTextXml};
|
|
||||||
}
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
const imgBuffer = this.options.getImage(value, part.value);
|
|
||||||
resolve(imgBuffer);
|
|
||||||
}).then((imgBuffer) => {
|
|
||||||
const rId = imgManager.addImageRels(this.getNextImageName(), imgBuffer);
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
const sizePixel = this.options.getSize(imgBuffer, value, part.value);
|
|
||||||
resolve(sizePixel);
|
|
||||||
}).then((sizePixel) => {
|
|
||||||
return {
|
|
||||||
rId: rId,
|
|
||||||
sizePixel: sizePixel,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getRenderedPart(part, rId, sizePixel) {
|
|
||||||
if (isNaN(rId)) {
|
|
||||||
throw new Error("rId is NaN, aborting");
|
|
||||||
}
|
|
||||||
const size = [DocUtils.convertPixelsToEmus(sizePixel[0]), DocUtils.convertPixelsToEmus(sizePixel[1])];
|
|
||||||
const centered = (this.options.centered || part.centered);
|
|
||||||
let newText;
|
|
||||||
if (this.fileType === "pptx") {
|
|
||||||
newText = this.getRenderedPartPptx(part, rId, size, centered);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
newText = this.getRenderedPartDocx(rId, size, centered);
|
|
||||||
}
|
|
||||||
return {value: newText};
|
|
||||||
}
|
|
||||||
getRenderedPartPptx(part, rId, size, centered) {
|
|
||||||
const offset = {x: parseInt(part.offset.x, 10), y: parseInt(part.offset.y, 10)};
|
|
||||||
const cellCX = parseInt(part.ext.cx, 10) || 1;
|
|
||||||
const cellCY = parseInt(part.ext.cy, 10) || 1;
|
|
||||||
const imgW = parseInt(size[0], 10) || 1;
|
|
||||||
const imgH = parseInt(size[1], 10) || 1;
|
|
||||||
if (centered) {
|
|
||||||
offset.x = Math.round(offset.x + (cellCX / 2) - (imgW / 2));
|
|
||||||
offset.y = Math.round(offset.y + (cellCY / 2) - (imgH / 2));
|
|
||||||
}
|
|
||||||
return templates.getPptxImageXml(rId, [imgW, imgH], offset);
|
|
||||||
}
|
|
||||||
getRenderedPartDocx(rId, size, centered) {
|
|
||||||
return centered ? templates.getImageXmlCentered(rId, size) : templates.getImageXml(rId, size);
|
|
||||||
}
|
|
||||||
getNextImageName() {
|
|
||||||
const name = `image_generated_${this.imageNumber}.png`;
|
|
||||||
this.imageNumber++;
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = ImageModule;
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "docxtemplater-image-module-free",
|
|
||||||
"version": "1.1.1",
|
|
||||||
"description": "Open Source Image Module for docxtemplater",
|
|
||||||
"main": "js/index.js",
|
|
||||||
"scripts": {
|
|
||||||
"test:coverage": "istanbul cover _mocha -- es6/test.js",
|
|
||||||
"compile": "rimraf js && mkdirp js && babel es6 --out-dir js",
|
|
||||||
"preversion": "npm test && npm run browserify && npm run uglify",
|
|
||||||
"test:compiled": "mocha js/test.js",
|
|
||||||
"test:es6": "mocha es6/test.js",
|
|
||||||
"lint": "eslint .",
|
|
||||||
"test": "npm run compile && npm run test:compiled",
|
|
||||||
"browserify": "rimraf build && mkdirp build && browserify --insert-global-vars __filename,__dirname -r ./js/index.js -s ImageModule > build/imagemodule.js",
|
|
||||||
"uglify": "uglifyjs build/imagemodule.js > build/imagemodule.min.js"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"babel-cli": "^6.11.4",
|
|
||||||
"babel-eslint": "^7.1.1",
|
|
||||||
"babel-preset-es2015": "^6.3.13",
|
|
||||||
"browserify": "^14.0.0",
|
|
||||||
"chai": "^3.4.1",
|
|
||||||
"docxtemplater": "^3.0.0",
|
|
||||||
"eslint": "^3.15.0",
|
|
||||||
"image-size": "^0.5.1",
|
|
||||||
"istanbul": "^0.4.5",
|
|
||||||
"jszip": "^2.6.1",
|
|
||||||
"mkdirp": "^0.5.1",
|
|
||||||
"mocha": "^3.2.0",
|
|
||||||
"rimraf": "^2.5.4",
|
|
||||||
"uglifyjs": "^2.4.10"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/evilc0des/docxtemplater-image-module-free"
|
|
||||||
},
|
|
||||||
"author": "Dk Saha",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"xmldom": "^0.1.27"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,112 +0,0 @@
|
|||||||
/******/ (function(modules) { // webpackBootstrap
|
|
||||||
/******/ // The module cache
|
|
||||||
/******/ var installedModules = {};
|
|
||||||
/******/
|
|
||||||
/******/ // The require function
|
|
||||||
/******/ function __webpack_require__(moduleId) {
|
|
||||||
/******/
|
|
||||||
/******/ // Check if module is in cache
|
|
||||||
/******/ if(installedModules[moduleId]) {
|
|
||||||
/******/ return installedModules[moduleId].exports;
|
|
||||||
/******/ }
|
|
||||||
/******/ // Create a new module (and put it into the cache)
|
|
||||||
/******/ var module = installedModules[moduleId] = {
|
|
||||||
/******/ i: moduleId,
|
|
||||||
/******/ l: false,
|
|
||||||
/******/ exports: {}
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // Execute the module function
|
|
||||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
||||||
/******/
|
|
||||||
/******/ // Flag the module as loaded
|
|
||||||
/******/ module.l = true;
|
|
||||||
/******/
|
|
||||||
/******/ // Return the exports of the module
|
|
||||||
/******/ return module.exports;
|
|
||||||
/******/ }
|
|
||||||
/******/
|
|
||||||
/******/
|
|
||||||
/******/ // expose the modules object (__webpack_modules__)
|
|
||||||
/******/ __webpack_require__.m = modules;
|
|
||||||
/******/
|
|
||||||
/******/ // expose the module cache
|
|
||||||
/******/ __webpack_require__.c = installedModules;
|
|
||||||
/******/
|
|
||||||
/******/ // define getter function for harmony exports
|
|
||||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
||||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
||||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
||||||
/******/ }
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // define __esModule on exports
|
|
||||||
/******/ __webpack_require__.r = function(exports) {
|
|
||||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
||||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
||||||
/******/ }
|
|
||||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // create a fake namespace object
|
|
||||||
/******/ // mode & 1: value is a module id, require it
|
|
||||||
/******/ // mode & 2: merge all properties of value into the ns
|
|
||||||
/******/ // mode & 4: return value when already ns object
|
|
||||||
/******/ // mode & 8|1: behave like require
|
|
||||||
/******/ __webpack_require__.t = function(value, mode) {
|
|
||||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
||||||
/******/ if(mode & 8) return value;
|
|
||||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
||||||
/******/ var ns = Object.create(null);
|
|
||||||
/******/ __webpack_require__.r(ns);
|
|
||||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
||||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
||||||
/******/ return ns;
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
||||||
/******/ __webpack_require__.n = function(module) {
|
|
||||||
/******/ var getter = module && module.__esModule ?
|
|
||||||
/******/ function getDefault() { return module['default']; } :
|
|
||||||
/******/ function getModuleExports() { return module; };
|
|
||||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
||||||
/******/ return getter;
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // Object.prototype.hasOwnProperty.call
|
|
||||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
||||||
/******/
|
|
||||||
/******/ // __webpack_public_path__
|
|
||||||
/******/ __webpack_require__.p = "";
|
|
||||||
/******/
|
|
||||||
/******/
|
|
||||||
/******/ // Load entry module and return exports
|
|
||||||
/******/ return __webpack_require__(__webpack_require__.s = "./es6/index_IE.js");
|
|
||||||
/******/ })
|
|
||||||
/************************************************************************/
|
|
||||||
/******/ ({
|
|
||||||
|
|
||||||
/***/ "../node_modules/webpack/buildin/global.js":
|
|
||||||
/*!*************************************************!*\
|
|
||||||
!*** ../node_modules/webpack/buildin/global.js ***!
|
|
||||||
\*************************************************/
|
|
||||||
/*! no static exports found */
|
|
||||||
/***/ (function(module, exports) {
|
|
||||||
|
|
||||||
eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack:///../node_modules/webpack/buildin/global.js?");
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ "./es6/index_IE.js":
|
|
||||||
/*!*************************!*\
|
|
||||||
!*** ./es6/index_IE.js ***!
|
|
||||||
\*************************/
|
|
||||||
/*! no static exports found */
|
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
eval("/* WEBPACK VAR INJECTION */(function(global) {/* global IEBinaryToArray_ByteStr, IEBinaryToArray_ByteStr_Last */\n // Adapted from http://stackoverflow.com/questions/1095102/how-do-i-load-binary-image-data-using-javascript-and-xmlhttprequest\n\nvar IEBinaryToArray_ByteStr_Script = \"<!-- IEBinaryToArray_ByteStr -->\\r\\n\" + \"<script type='text/vbscript'>\\r\\n\" + \"Function IEBinaryToArray_ByteStr(Binary)\\r\\n\" + \" IEBinaryToArray_ByteStr = CStr(Binary)\\r\\n\" + \"End Function\\r\\n\" + \"Function IEBinaryToArray_ByteStr_Last(Binary)\\r\\n\" + \" Dim lastIndex\\r\\n\" + \" lastIndex = LenB(Binary)\\r\\n\" + \" if lastIndex mod 2 Then\\r\\n\" + \" IEBinaryToArray_ByteStr_Last = Chr( AscB( MidB( Binary, lastIndex, 1 ) ) )\\r\\n\" + \" Else\\r\\n\" + \" IEBinaryToArray_ByteStr_Last = \" + '\"\"' + \"\\r\\n\" + \" End If\\r\\n\" + \"End Function\\r\\n\" + \"</script>\\r\\n\"; // inject VBScript\n\ndocument.write(IEBinaryToArray_ByteStr_Script);\n\nglobal.PizZipUtils._getBinaryFromXHR = function (xhr) {\n var binary = xhr.responseBody;\n var byteMapping = {};\n\n for (var i = 0; i < 256; i++) {\n for (var j = 0; j < 256; j++) {\n byteMapping[String.fromCharCode(i + (j << 8))] = String.fromCharCode(i) + String.fromCharCode(j);\n }\n }\n\n var rawBytes = IEBinaryToArray_ByteStr(binary);\n var lastChr = IEBinaryToArray_ByteStr_Last(binary);\n return rawBytes.replace(/[\\s\\S]/g, function (match) {\n return byteMapping[match];\n }) + lastChr;\n};\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ \"../node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack:///./es6/index_IE.js?");
|
|
||||||
|
|
||||||
/***/ })
|
|
||||||
|
|
||||||
/******/ });
|
|
||||||
@ -1,102 +0,0 @@
|
|||||||
window["PizZipUtils"] =
|
|
||||||
/******/ (function(modules) { // webpackBootstrap
|
|
||||||
/******/ // The module cache
|
|
||||||
/******/ var installedModules = {};
|
|
||||||
/******/
|
|
||||||
/******/ // The require function
|
|
||||||
/******/ function __webpack_require__(moduleId) {
|
|
||||||
/******/
|
|
||||||
/******/ // Check if module is in cache
|
|
||||||
/******/ if(installedModules[moduleId]) {
|
|
||||||
/******/ return installedModules[moduleId].exports;
|
|
||||||
/******/ }
|
|
||||||
/******/ // Create a new module (and put it into the cache)
|
|
||||||
/******/ var module = installedModules[moduleId] = {
|
|
||||||
/******/ i: moduleId,
|
|
||||||
/******/ l: false,
|
|
||||||
/******/ exports: {}
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // Execute the module function
|
|
||||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
||||||
/******/
|
|
||||||
/******/ // Flag the module as loaded
|
|
||||||
/******/ module.l = true;
|
|
||||||
/******/
|
|
||||||
/******/ // Return the exports of the module
|
|
||||||
/******/ return module.exports;
|
|
||||||
/******/ }
|
|
||||||
/******/
|
|
||||||
/******/
|
|
||||||
/******/ // expose the modules object (__webpack_modules__)
|
|
||||||
/******/ __webpack_require__.m = modules;
|
|
||||||
/******/
|
|
||||||
/******/ // expose the module cache
|
|
||||||
/******/ __webpack_require__.c = installedModules;
|
|
||||||
/******/
|
|
||||||
/******/ // define getter function for harmony exports
|
|
||||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
||||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
||||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
||||||
/******/ }
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // define __esModule on exports
|
|
||||||
/******/ __webpack_require__.r = function(exports) {
|
|
||||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
||||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
||||||
/******/ }
|
|
||||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // create a fake namespace object
|
|
||||||
/******/ // mode & 1: value is a module id, require it
|
|
||||||
/******/ // mode & 2: merge all properties of value into the ns
|
|
||||||
/******/ // mode & 4: return value when already ns object
|
|
||||||
/******/ // mode & 8|1: behave like require
|
|
||||||
/******/ __webpack_require__.t = function(value, mode) {
|
|
||||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
||||||
/******/ if(mode & 8) return value;
|
|
||||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
||||||
/******/ var ns = Object.create(null);
|
|
||||||
/******/ __webpack_require__.r(ns);
|
|
||||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
||||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
||||||
/******/ return ns;
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
||||||
/******/ __webpack_require__.n = function(module) {
|
|
||||||
/******/ var getter = module && module.__esModule ?
|
|
||||||
/******/ function getDefault() { return module['default']; } :
|
|
||||||
/******/ function getModuleExports() { return module; };
|
|
||||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
||||||
/******/ return getter;
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // Object.prototype.hasOwnProperty.call
|
|
||||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
||||||
/******/
|
|
||||||
/******/ // __webpack_public_path__
|
|
||||||
/******/ __webpack_require__.p = "";
|
|
||||||
/******/
|
|
||||||
/******/
|
|
||||||
/******/ // Load entry module and return exports
|
|
||||||
/******/ return __webpack_require__(__webpack_require__.s = "./es6/index.js");
|
|
||||||
/******/ })
|
|
||||||
/************************************************************************/
|
|
||||||
/******/ ({
|
|
||||||
|
|
||||||
/***/ "./es6/index.js":
|
|
||||||
/*!**********************!*\
|
|
||||||
!*** ./es6/index.js ***!
|
|
||||||
\**********************/
|
|
||||||
/*! no static exports found */
|
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
eval("\n\nvar PizZipUtils = {}; // just use the responseText with xhr1, response with xhr2.\n// The transformation doesn't throw away high-order byte (with responseText)\n// because PizZip handles that case. If not used with PizZip, you may need to\n// do it, see https://developer.mozilla.org/En/Using_XMLHttpRequest#Handling_binary_data\n\nPizZipUtils._getBinaryFromXHR = function (xhr) {\n // for xhr.responseText, the 0xFF mask is applied by PizZip\n return xhr.response || xhr.responseText;\n}; // taken from jQuery\n\n\nfunction createStandardXHR() {\n try {\n return new window.XMLHttpRequest();\n } catch (e) {}\n}\n\nfunction createActiveXHR() {\n try {\n return new window.ActiveXObject(\"Microsoft.XMLHTTP\");\n } catch (e) {}\n} // Create the request object\n\n\nvar createXHR = window.ActiveXObject ?\n/* Microsoft failed to properly\n * implement the XMLHttpRequest in IE7 (can't request local files),\n * so we use the ActiveXObject when it is available\n * Additionally XMLHttpRequest can be disabled in IE7/IE8 so\n * we need a fallback.\n */\nfunction () {\n return createStandardXHR() || createActiveXHR();\n} : // For all other browsers, use the standard XMLHttpRequest object\ncreateStandardXHR;\n\nPizZipUtils.getBinaryContent = function (path, callback) {\n /*\n * Here is the tricky part : getting the data.\n * In firefox/chrome/opera/... setting the mimeType to 'text/plain; charset=x-user-defined'\n * is enough, the result is in the standard xhr.responseText.\n * cf https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest#Receiving_binary_data_in_older_browsers\n * In IE <= 9, we must use (the IE only) attribute responseBody\n * (for binary data, its content is different from responseText).\n * In IE 10, the 'charset=x-user-defined' trick doesn't work, only the\n * responseType will work :\n * http://msdn.microsoft.com/en-us/library/ie/hh673569%28v=vs.85%29.aspx#Binary_Object_upload_and_download\n *\n * I'd like to use jQuery to avoid this XHR madness, but it doesn't support\n * the responseType attribute : http://bugs.jquery.com/ticket/11461\n */\n try {\n var xhr = createXHR();\n xhr.open(\"GET\", path, true); // recent browsers\n\n if (\"responseType\" in xhr) {\n xhr.responseType = \"arraybuffer\";\n } // older browser\n\n\n if (xhr.overrideMimeType) {\n xhr.overrideMimeType(\"text/plain; charset=x-user-defined\");\n }\n\n xhr.onreadystatechange = function (evt) {\n var file, err; // use `xhr` and not `this`... thanks IE\n\n if (xhr.readyState === 4) {\n if (xhr.status === 200 || xhr.status === 0) {\n file = null;\n err = null;\n\n try {\n file = PizZipUtils._getBinaryFromXHR(xhr);\n } catch (e) {\n err = new Error(e);\n }\n\n callback(err, file);\n } else {\n callback(new Error(\"Ajax error for \" + path + \" : \" + this.status + \" \" + this.statusText), null);\n }\n }\n };\n\n xhr.send();\n } catch (e) {\n callback(new Error(e), null);\n }\n};\n\nmodule.exports = PizZipUtils;\n\n//# sourceURL=webpack://PizZipUtils/./es6/index.js?");
|
|
||||||
|
|
||||||
/***/ })
|
|
||||||
|
|
||||||
/******/ });
|
|
||||||
|
Before Width: | Height: | Size: 665 B |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 175 B |
|
Before Width: | Height: | Size: 96 B |
|
Before Width: | Height: | Size: 109 B |
|
Before Width: | Height: | Size: 74 B |
|
Before Width: | Height: | Size: 84 B |
@ -1,16 +0,0 @@
|
|||||||
body { padding: 0; margin: 0 }
|
|
||||||
#unity-container { position: absolute }
|
|
||||||
#unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) }
|
|
||||||
#unity-container.unity-mobile { position: fixed; width: 100%; height: 100% }
|
|
||||||
#unity-canvas { background: #231F20 }
|
|
||||||
.unity-mobile #unity-canvas { width: 100%; height: 100% }
|
|
||||||
#unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none }
|
|
||||||
#unity-logo { width: 154px; height: 130px; background: url('unity-logo-dark.png') no-repeat center }
|
|
||||||
#unity-progress-bar-empty { width: 141px; height: 18px; margin-top: 10px; margin-left: 6.5px; background: url('progress-bar-empty-dark.png') no-repeat center }
|
|
||||||
#unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-dark.png') no-repeat center }
|
|
||||||
#unity-footer { position: relative }
|
|
||||||
.unity-mobile #unity-footer { display: none }
|
|
||||||
#unity-webgl-logo { float:left; width: 204px; height: 38px; background: url('webgl-logo.png') no-repeat center }
|
|
||||||
#unity-build-title { float: right; margin-right: 10px; line-height: 38px; font-family: arial; font-size: 18px }
|
|
||||||
#unity-fullscreen-button { cursor:pointer; float: right; width: 38px; height: 38px; background: url('fullscreen-button.png') no-repeat center }
|
|
||||||
#unity-warning { position: absolute; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none }
|
|
||||||
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
@ -1,122 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en-us">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<title>Unity WebGL Player | VirtualFramwork</title>
|
|
||||||
<link rel="shortcut icon" href="TemplateData/favicon.ico">
|
|
||||||
<link rel="stylesheet" href="TemplateData/style.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="unity-container" class="unity-desktop">
|
|
||||||
<canvas id="unity-canvas" width=1280 height=720 tabindex="-1"></canvas>
|
|
||||||
<div id="unity-loading-bar">
|
|
||||||
<div id="unity-logo"></div>
|
|
||||||
<div id="unity-progress-bar-empty">
|
|
||||||
<div id="unity-progress-bar-full"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="unity-warning"> </div>
|
|
||||||
<div id="unity-footer">
|
|
||||||
<div id="unity-webgl-logo"></div>
|
|
||||||
<div id="unity-fullscreen-button"></div>
|
|
||||||
<div id="unity-build-title">VirtualFramwork</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
|
|
||||||
var container = document.querySelector("#unity-container");
|
|
||||||
var canvas = document.querySelector("#unity-canvas");
|
|
||||||
var loadingBar = document.querySelector("#unity-loading-bar");
|
|
||||||
var progressBarFull = document.querySelector("#unity-progress-bar-full");
|
|
||||||
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
|
|
||||||
var warningBanner = document.querySelector("#unity-warning");
|
|
||||||
|
|
||||||
// Shows a temporary message banner/ribbon for a few seconds, or
|
|
||||||
// a permanent error message on top of the canvas if type=='error'.
|
|
||||||
// If type=='warning', a yellow highlight color is used.
|
|
||||||
// Modify or remove this function to customize the visually presented
|
|
||||||
// way that non-critical warnings and error messages are presented to the
|
|
||||||
// user.
|
|
||||||
function unityShowBanner(msg, type) {
|
|
||||||
function updateBannerVisibility() {
|
|
||||||
warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
|
|
||||||
}
|
|
||||||
var div = document.createElement('div');
|
|
||||||
div.innerHTML = msg;
|
|
||||||
warningBanner.appendChild(div);
|
|
||||||
if (type == 'error') div.style = 'background: red; padding: 10px;';
|
|
||||||
else {
|
|
||||||
if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
|
|
||||||
setTimeout(function() {
|
|
||||||
warningBanner.removeChild(div);
|
|
||||||
updateBannerVisibility();
|
|
||||||
}, 5000);
|
|
||||||
}
|
|
||||||
updateBannerVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
var buildUrl = "Build";
|
|
||||||
var loaderUrl = buildUrl + "/ceshi.loader.js";
|
|
||||||
var config = {
|
|
||||||
dataUrl: buildUrl + "/ceshi.data.unityweb",
|
|
||||||
frameworkUrl: buildUrl + "/ceshi.framework.js.unityweb",
|
|
||||||
codeUrl: buildUrl + "/ceshi.wasm.unityweb",
|
|
||||||
streamingAssetsUrl: "StreamingAssets",
|
|
||||||
companyName: "DefaultCompany",
|
|
||||||
productName: "VirtualFramwork",
|
|
||||||
productVersion: "0.1",
|
|
||||||
showBanner: unityShowBanner,
|
|
||||||
};
|
|
||||||
|
|
||||||
// By default, Unity keeps WebGL canvas render target size matched with
|
|
||||||
// the DOM size of the canvas element (scaled by window.devicePixelRatio)
|
|
||||||
// Set this to false if you want to decouple this synchronization from
|
|
||||||
// happening inside the engine, and you would instead like to size up
|
|
||||||
// the canvas DOM size and WebGL render target sizes yourself.
|
|
||||||
// config.matchWebGLToCanvasSize = false;
|
|
||||||
|
|
||||||
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
|
|
||||||
// Mobile device style: fill the whole browser client area with the game canvas:
|
|
||||||
|
|
||||||
var meta = document.createElement('meta');
|
|
||||||
meta.name = 'viewport';
|
|
||||||
meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
|
|
||||||
document.getElementsByTagName('head')[0].appendChild(meta);
|
|
||||||
container.className = "unity-mobile";
|
|
||||||
canvas.className = "unity-mobile";
|
|
||||||
|
|
||||||
// To lower canvas resolution on mobile devices to gain some
|
|
||||||
// performance, uncomment the following line:
|
|
||||||
// config.devicePixelRatio = 1;
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Desktop style: Render the game canvas in a window that can be maximized to fullscreen:
|
|
||||||
|
|
||||||
canvas.style.width = "1280px";
|
|
||||||
canvas.style.height = "720px";
|
|
||||||
}
|
|
||||||
|
|
||||||
loadingBar.style.display = "block";
|
|
||||||
|
|
||||||
var script = document.createElement("script");
|
|
||||||
script.src = loaderUrl;
|
|
||||||
script.onload = () => {
|
|
||||||
createUnityInstance(canvas, config, (progress) => {
|
|
||||||
progressBarFull.style.width = 100 * progress + "%";
|
|
||||||
}).then((unityInstance) => {
|
|
||||||
loadingBar.style.display = "none";
|
|
||||||
fullscreenButton.onclick = () => {
|
|
||||||
document.makeFullscreen('unity-container');
|
|
||||||
};
|
|
||||||
}).catch((message) => {
|
|
||||||
alert(message);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
document.body.appendChild(script);
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||