19 #define HTML_PREFIX "<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\"/>\n </head>\n <body>\n <!-- three.js scripts -->\n <!-- startup three.js -->\n <script src=\"jsmodules/three.min.js\"></script>\n <script src=\"jsmodules/three.module.js\"></script>\n <script src=\"jsmodules/gif.js\"></script>\n <!-- load models and look at them-->\n <script src=\"jsmodules/OBJLoader.js\"></script>\n <script src=\"jsmodules/MTLLoader.js\"></script>\n <!-- postprocessing -->\n <script src=\"jsmodules/CopyShader.js\"></script>\n <script src=\"jsmodules/Pass.js\"></script>\n <script src=\"jsmodules/ShaderPass.js\"></script>\n <script src=\"jsmodules/MaskPass.js\"></script>\n <script src=\"jsmodules/EffectComposer.js\"></script>\n <script src=\"jsmodules/RenderPass.js\"></script>\n <script src=\"jsmodules/DigitalGlitch.js\"></script>\n <script src=\"jsmodules/GlitchPass.js\"></script>\n\n <!--Other outside libraries -->\n <script type=\"text/javascript\" src=\"jsmodules/jquery-3.5.1.min.js\"></script>\n <script type=\"text/javascript\" src=\"jsmodules/dat.gui.min.js\"></script>\n <script type=\"text/javascript\" src=\"jsmodules/gl-matrix-min.js\"></script>\n\n <!-- Our code -->\n <script type=\"text/javascript\" src=\"cameras3d.js\"></script>\n <script type=\"text/javascript\" src=\"scenecanvas.js\"></script>\n\n\n";
23 stringstream sceneCode;
27 sceneCode <<
"let canvas = new SceneCanvas();\n";
47 void addBox(
double cx,
double cy,
double cz,
double xlen,
48 double ylen,
double zlen,
49 double r,
double g,
double b,
50 double roughness,
double metalness,
51 double rx,
double ry,
double rz) {
52 sceneCode <<
"canvas.addBox(" << cx <<
"," << cy <<
"," << cz <<
"," << xlen <<
"," << ylen <<
"," << zlen <<
"," << r <<
"," << g <<
"," << b <<
"," << roughness <<
"," << metalness <<
"," << rx <<
"," << ry <<
"," << rz <<
");\n";
69 void addBox(
double cx,
double cy,
double cz,
70 double xlen,
double ylen,
double zlen,
71 double r,
double g,
double b,
72 double roughness,
double metalness) {
73 addBox(cx, cy, cz, xlen, ylen, zlen, r, g, b, roughness, metalness, 0, 0, 0);
95 void addCylinder(
double cx,
double cy,
double cz,
double radius,
96 double height,
double r,
double g,
double b,
97 double roughness,
double metalness,
98 double rx,
double ry,
double rz,
99 double sx,
double sy,
double sz) {
100 sceneCode <<
"canvas.addCylinder(" << cx <<
"," << cy <<
"," << cz <<
"," << radius <<
"," << height <<
"," << r <<
"," << g <<
"," << b <<
"," << roughness <<
"," << metalness <<
"," << rx <<
"," << ry <<
"," << rz <<
"," << sx <<
"," << sy <<
"," << sz <<
");\n";
117 double height,
double r,
double g,
double b,
118 double roughness,
double metalness) {
119 addCylinder(cx, cy, cz, radius, height, r, g, b, roughness, metalness, 0, 0, 0, 1, 1, 1);
141 void addCone(
double cx,
double cy,
double cz,
double radius,
142 double height,
double r,
double g,
double b,
143 double roughness,
double metalness,
144 double rx,
double ry,
double rz,
145 double sx,
double sy,
double sz) {
146 sceneCode <<
"canvas.addCone(" << cx <<
"," << cy <<
"," << cz <<
"," << radius <<
"," << height <<
"," << r <<
"," << g <<
"," << b <<
"," << roughness <<
"," << metalness <<
"," << rx <<
"," << ry <<
"," << rz <<
"," << sx <<
"," << sy <<
"," << sz <<
");";
162 void addCone(
double cx,
double cy,
double cz,
double radius,
163 double height,
double r,
double g,
double b,
164 double roughness,
double metalness) {
165 addCone(cx, cy, cz, radius, height, r, g, b, roughness, metalness, 0, 0, 0, 1, 1, 1);
186 double radx,
double rady,
double radz,
187 double r,
double g,
double b,
188 double roughness,
double metalness,
189 double rx,
double ry,
double rz) {
190 sceneCode <<
"canvas.addEllipsoid(" << cx <<
"," << cy <<
"," << cz <<
"," << radx <<
"," << rady <<
"," << radz <<
"," << r <<
"," << g <<
"," << b <<
"," << roughness <<
"," << metalness <<
"," << rx <<
"," << ry <<
"," << rz <<
");\n";
208 double radx,
double rady,
double radz,
209 double r,
double g,
double b,
210 double roughness,
double metalness) {
211 addEllipsoid(cx, cy, cz, radx, rady, radz, r, g, b, roughness, metalness, 0, 0, 0);
226 void addSphere(
double cx,
double cy,
double cz,
double radius,
227 double r,
double g,
double b,
228 double roughness,
double metalness) {
229 addEllipsoid(cx, cy, cz, radius, radius, radius, r, g, b, roughness, metalness);
252 double cx,
double cy,
double cz,
253 double rx,
double ry,
double rz,
254 double sx,
double sy,
double sz,
255 double r,
double g,
double b,
256 double roughness,
double metalness) {
257 sceneCode <<
"canvas.addMesh(\"" << path <<
"\"," << cx <<
"," << cy <<
"," << cz <<
"," << rx <<
"," << ry <<
"," << rz <<
"," << sx <<
"," << sy <<
"," << sz <<
"," << r <<
"," << g <<
"," << b <<
"," << roughness <<
"," << metalness <<
");\n";
277 double cx,
double cy,
double cz,
278 double rx,
double ry,
double rz,
279 double sx,
double sy,
double sz,
281 sceneCode <<
"canvas.addTexturedMesh(\"" << path <<
"\",\"" << matpath <<
"\"," << cx <<
"," << cy <<
"," << cz <<
"," << rx <<
"," << ry <<
"," << rz <<
"," << sx <<
"," << sy <<
"," << sz <<
"," << shininess <<
");\n";
292 void addCamera(
double x,
double y,
double z,
double rot) {
293 sceneCode <<
"canvas.addCamera(" << x <<
"," << y <<
"," << z <<
"," << rot <<
");\n";
307 void addPointLight(
double x,
double y,
double z,
double r,
double g,
double b,
double intensity) {
308 sceneCode <<
"canvas.addPointLight(" << x <<
"," << y <<
"," << z <<
"," << r <<
"," << g <<
"," << b <<
"," << intensity <<
");\n";
324 sceneCode <<
"canvas.addDirectionalLight(" << x <<
"," << y <<
"," << z <<
"," << r <<
"," << g <<
"," << b <<
"," << intensity <<
");\n";
333 std::ofstream out(filename.c_str());
336 out << sceneCode.str();
337 out <<
"canvas.name = \"" << sceneName <<
"\";\n";
338 out <<
"canvas.repaint();\n</script>\n </body>\n</html>";
void addPointLight(double x, double y, double z, double r, double g, double b, double intensity)
Definition: Scene3D.h:307
void addCylinder(double cx, double cy, double cz, double radius, double height, double r, double g, double b, double roughness, double metalness, double rx, double ry, double rz, double sx, double sy, double sz)
Definition: Scene3D.h:95
void addEllipsoid(double cx, double cy, double cz, double radx, double rady, double radz, double r, double g, double b, double roughness, double metalness)
Definition: Scene3D.h:207
void addDirectionalLight(double x, double y, double z, double r, double g, double b, double intensity)
Definition: Scene3D.h:323
void addCamera(double x, double y, double z, double rot)
Definition: Scene3D.h:292
void addCylinder(double cx, double cy, double cz, double radius, double height, double r, double g, double b, double roughness, double metalness)
Definition: Scene3D.h:116
void addSphere(double cx, double cy, double cz, double radius, double r, double g, double b, double roughness, double metalness)
Definition: Scene3D.h:226
void addMesh(string path, double cx, double cy, double cz, double rx, double ry, double rz, double sx, double sy, double sz, double r, double g, double b, double roughness, double metalness)
Definition: Scene3D.h:251
void addEllipsoid(double cx, double cy, double cz, double radx, double rady, double radz, double r, double g, double b, double roughness, double metalness, double rx, double ry, double rz)
Definition: Scene3D.h:185
void addBox(double cx, double cy, double cz, double xlen, double ylen, double zlen, double r, double g, double b, double roughness, double metalness, double rx, double ry, double rz)
Definition: Scene3D.h:47
void saveScene(string filename, string sceneName)
Definition: Scene3D.h:332
void addTexturedMesh(string path, string matpath, double cx, double cy, double cz, double rx, double ry, double rz, double sx, double sy, double sz, double shininess)
Definition: Scene3D.h:276
void addCone(double cx, double cy, double cz, double radius, double height, double r, double g, double b, double roughness, double metalness)
Definition: Scene3D.h:162
void addBox(double cx, double cy, double cz, double xlen, double ylen, double zlen, double r, double g, double b, double roughness, double metalness)
Definition: Scene3D.h:69
void addCone(double cx, double cy, double cz, double radius, double height, double r, double g, double b, double roughness, double metalness, double rx, double ry, double rz, double sx, double sy, double sz)
Definition: Scene3D.h:141