Commit ad92264b authored by frankie's avatar frankie 💬

cleanup of resources and scripts for packaging with uglifyjs

parent 42cfb7cc
/*
_________ ____ .-. _________/ ____ .-. ____
_________ ____ .-. _________/ ____ .-. ____
__|__ (_)_/(_)( )____< \| ( ) (_)
`-' `-'
`-' `-'
libre video game bazaar
____________________________________ ? ____________________________________
(._.)
This file is part of sysiphus project
For the latest info, see http://polymorph.cool/
Copyright (c) 2018 polymorph.cool
All rights reserved.
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
___________________________________( ^3^)_____________________________________
ascii font: rotated by MikeChat & myflix
have fun and be cool :)
*/
function BoneScalePreset() {
......@@ -47,7 +47,7 @@ function BoneScalePreset() {
this.name = undefined;
this.bone_scale = undefined;
this.init = function( bones, json = undefined ) {
this.init = function( bones, json ) {
this.bone_scale = {};
if ( json === undefined ) {
this.unit( bones );
......@@ -66,7 +66,7 @@ function BoneScalePreset() {
break;
}
}
if ( found ) {
if ( found ) {
continue;
}
this.bone_scale[bn] = default_scale.clone();
......@@ -82,7 +82,7 @@ function BoneScalePreset() {
}
this.parse_bone_vec3 = function( name ) {
return new THREE.Vector3(
return new THREE.Vector3(
this.json.bones[name]["vec3"][0],
this.json.bones[name]["vec3"][1],
this.json.bones[name]["vec3"][2]);
......@@ -97,4 +97,4 @@ function BoneScalePreset() {
return v3.lerp( this.bone_scale[bone_name], alpha );
};
};
\ No newline at end of file
};
......@@ -233,7 +233,7 @@ function SysiphusAvatar() {
};
this.load_bone = function( obj, parent = undefined ) {
this.load_bone = function( obj, parent ) {
var sb = new SysiphusBone();
sb.bone = obj;
......@@ -425,7 +425,7 @@ function SysiphusAvatar() {
return this.current_anim.name;
};
this.set_animation_name = function( name, on_loop = undefined ) {
this.set_animation_name = function( name, on_loop ) {
if (
name == this.current_anim.name &&
......
......@@ -85,7 +85,7 @@ function SysiphusBone() {
this.ik_weight = 1;
this.ik_depth = 0;
this.render_world_mat = function( mat, use_backup = false ) {
this.render_world_mat = function( mat, use_backup ) {
if ( this.parent !== undefined ) {
if ( use_backup ) {
mat.copy(
......
......@@ -41,7 +41,7 @@ DONE
*/
function RandomTrigger( min, max, listener = undefined ) {
function RandomTrigger( min, max, listener ) {
this.second_min = min;
this.second_max = max;
......
......@@ -147,10 +147,7 @@ function Tracker() {
} );
}
this.track = function(
name = undefined,
duration = undefined,
speed = undefined ) {
this.track = function( name, duration, speed ) {
this.active_track_name = name;
......
......@@ -62,7 +62,7 @@ Interpolation.halo = function( value ) {
return ( sinus1 * (1-value) + sinus2 * value );
};
Interpolation.new_interpolation = function( name, init, speed, method = undefined ) {
Interpolation.new_interpolation = function( name, init, speed, method ) {
var inter = {
name: name,
......
'''
REQUIREMENT
install nodejs
$ sudo apt install nodejs
$ sudo apt-get install nodejs-legacy
install uglify-js
$ sudo npm install -g uglify-js
$ sudo npm install -g uglifyjs-webpack-plugin
'''
import os
import shutil
import errno
import re
import uuid
import subprocess
import ftplib
export_folder = "../package"
export_file = "index.html"
export_file_css = "sisyphus_#.css"
export_file_threejs = "three.js"
export_file_customjs = "sisyphus_#.js"
'''
CONFIGURATION
......@@ -12,7 +30,8 @@ CONFIGURATION
template_file = "template.html"
css_files = [ "css/normalize.css", "css/style.css" ]
js_files = [
threejs_files = [
"build/three.min.js",
"js/threejs/loaders/ColladaLoader.js",
"js/threejs/controls/OrbitControls.js",
......@@ -28,6 +47,9 @@ js_files = [
"js/threejs/shaders/ConvolutionShader.js",
"js/threejs/shaders/LuminosityHighPassShader.js",
"js/threejs/postprocessing/UnrealBloomPass.js",
]
customjs_files = [
"js/utils/Basics.js",
"js/utils/Interpolation.js",
"js/utils/MorphableMesh.js",
......@@ -52,7 +74,8 @@ GLOBAL VARS
'''
css_content = ""
js_content = ""
threejs_content = ""
customjs_content = ""
def copy(src, dst):
try:
......@@ -103,7 +126,10 @@ def minimize_string( s, complete = True ):
if complete:
return s.replace(' ', '').replace('\t', '').replace('\n', '').replace('\r', '')
else:
return s.replace(' ', '').replace('\t', '')
return s
def uglify( path ):
subprocess.call(["uglifyjs", path, "--compress", "--ie8", "--o", path ])
# cleaning the output path
for root, dirs, files in os.walk( export_folder+"/" ):
......@@ -126,12 +152,32 @@ for d in copy_files:
css_content = get_content( css_files, 'css' )
css_content = css_content.replace('../', '')
js_content = get_content( js_files, 'js' )
threejs_content = get_content( threejs_files, 'js' )
customjs_content = get_content( customjs_files, 'js' )
export_path = export_folder+'/'+export_file_threejs
with open( export_folder+'/'+export_file_threejs , 'w') as f:
f.write( threejs_content )
f.close()
uglify( export_path )
export_file_customjs = export_file_customjs.replace( "#", str(uuid.uuid1()) )
export_path = export_folder+'/'+export_file_customjs
with open( export_path, 'w') as f:
f.write( customjs_content )
f.close()
uglify( export_path )
export_file_css = export_file_css.replace( "#", str(uuid.uuid1()) )
export_path = export_folder+'/'+export_file_css
with open( export_path, 'w') as f:
f.write( css_content )
f.close()
template_content = open(template_file, 'r').read()
template_content = template_content.replace('<!--INCLUDE_LICENSE-->', license )
template_content = template_content.replace('<!--INCLUDE_CSS-->', '<style type="text/css">'+css_content+'</style>')
template_content = template_content.replace('<!--INCLUDE_JS-->', '<script type="text/javascript">'+js_content+'</script>')
template_content = template_content.replace('<!--INCLUDE_CSS-->', '<link rel="stylesheet" href="'+export_file_css+'"/>')
template_content = template_content.replace('<!--INCLUDE_JS-->', '<script src="'+export_file_threejs+'"></script><script src="'+export_file_customjs+'"></script>')
with open( export_folder+'/'+export_file , 'w') as f:
f.write( template_content )
......
......@@ -17,6 +17,7 @@
<meta name="description" content="Sisyphus is an absurd ergonomic simulation producing ‘Chairs’.">
<meta name="keywords" content="avatar, threejs, 3d, experimental, video game, transgender, queer">
<meta name="author" content="Simone Niquille & François Zajega">
<meta name="application-name" content="Sisyphus - online version">
<!--INCLUDE_CSS-->
</head>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment