Skip to content

Commit

Permalink
Merge pull request #2 from Tomas1337/findmypain_02072024
Browse files Browse the repository at this point in the history
TMWIH 16072024
  • Loading branch information
Tomas1337 authored Jul 15, 2024
2 parents 5dc8128 + f3a9985 commit 0b2ea1e
Show file tree
Hide file tree
Showing 15 changed files with 904 additions and 212 deletions.
Binary file added assets/reports/pain_report.pdf
Binary file not shown.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,18 @@
"create_dist_test": "npm run create_package_test && npm run lint && npm run test",
"create_package": "npm run generate_docs && npm run build_engine && npm run build_engine_module && npm run build_website && run-python3 tools/create_package.py",
"create_package_test": "npm run generate_docs && npm run build_engine && npm run build_engine_module && npm run build_website && run-python3 tools/create_package.py test",
"generate_docs": "run-python3 tools/generate_docs.py",
"copy-pdfmake": "node -e \"const fs = require('fs'); const path = require('path'); console.log('Current directory:', process.cwd()); const sources = ['node_modules/pdfmake/build/pdfmake.min.js', 'node_modules/pdfmake/build/vfs_fonts.js']; const dest = 'build/website_dev/'; if (!fs.existsSync(dest)) { fs.mkdirSync(dest, { recursive: true }); } sources.forEach(source => { const sourcePath = path.resolve(__dirname, source); const destPath = path.join(dest, path.basename(source)); if (fs.existsSync(sourcePath)) { fs.copyFileSync(sourcePath, destPath); console.log(`Copied ${sourcePath} to ${destPath}`); } else { console.error('Source file not found:', sourcePath); } });\"", "generate_docs": "run-python3 tools/generate_docs.py",
"build_dev": "npm run build_engine_dev && npm run build_website_dev",
"build_engine_dev": "npm run update_engine_exports && esbuild source/engine/main.js --bundle --minify --global-name=OV --sourcemap --outfile=build/engine_dev/o3dv.min.js",
"build_engine": "npm run update_engine_exports && esbuild source/engine/main.js --bundle --minify --global-name=OV --outfile=build/engine/o3dv.min.js",
"build_engine_module": "npm run update_engine_exports && rollup --config tools/rollup.js && tsc --project tools/tsconfig.json",
"build_website_dev": "esbuild source/website/index.js --bundle --minify --global-name=OV --sourcemap --loader:.ttf=file --loader:.woff=file --loader:.svg=file --outfile=build/website_dev/o3dv.website.min.js",
"build_website_dev": "npm run copy-pdfmake && esbuild source/website/index.js --bundle --minify --global-name=OV --sourcemap --loader:.ttf=file --loader:.woff=file --loader:.svg=file --outfile=build/website_dev/o3dv.website.min.js",
"build_website": "esbuild source/website/index.js --bundle --minify --global-name=OV --loader:.ttf=file --loader:.woff=file --loader:.svg=file --outfile=build/website/o3dv.website.min.js",
"update_engine_exports": "run-python3 tools/update_engine_exports.py"
},
"devDependencies": {
"@types/node": "^20.1.0",
"cpy-cli": "^5.0.0",
"esbuild": "^0.20.0",
"eslint": "^8.29.0",
"eslint-plugin-unused-imports": "^3.0.0",
Expand All @@ -76,6 +77,7 @@
"dependencies": {
"@simonwep/pickr": "1.9.0",
"fflate": "0.8.2",
"pdfmake": "^0.2.10",
"three": "0.163.0"
},
"eslintConfig": {
Expand Down
4 changes: 2 additions & 2 deletions source/engine/viewer/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ export class Navigation
this.clickDetector.Start (this.mouse.GetPosition ());

if (!this.enableCameraMovement) {
this.isMouseDown = true;
}
this.isMouseDown = true;
}
}

OnMouseMove (ev)
Expand Down
12 changes: 6 additions & 6 deletions source/website/css/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ a:hover

@media (max-width: 800px)
{

.only_full_width
{
display: none;
}

/* Remove or comment out the following block to ensure elements are not hidden on small screens */
/*
.only_full_width {
display: none;
}
*/
}
15 changes: 7 additions & 8 deletions source/website/css/dialogs.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ div.ov_modal_overlay
position: absolute;
}

div.ov_dialog
{
color: var(--ov_dialog_foreground_color);
background: var(--ov_dialog_background_color);
width: 400px;
padding: 20px;
box-shadow: var(--ov_shadow);
border-radius: 5px;
div.ov_dialog {
color: var(--ov_dialog_foreground_color);
background: var(--ov_dialog_background_color);
width: 80vw; /* Adjust width */
padding: 20px;
box-shadow: var(--ov_shadow);
border-radius: 5px;
}

div.ov_dialog div.ov_dialog_title
Expand Down
173 changes: 173 additions & 0 deletions source/website/css/sharingdialog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
.ov_dialog_form_container {
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
max-height: 80vh;
overflow-y: auto;
width: 90vw;
max-width: 1200px;
margin: auto;
}

.ov_dialog_step {
display: flex;
flex-direction: row;
gap: 15px;
}

.ov_dialog_title {
font-size: 1.5em;
margin-bottom: 10px;
color: #333;
}

.ov_dialog_description {
font-size: 1em;
margin-bottom: 20px;
color: #666;
}

.ov_dialog_label {
font-size: 1em;
margin-right: 10px;
color: #333;
flex: 0 0 150px; /* Adjust the width as needed */
}

.ov_dialog_input {
padding: 10px;
font-size: 1em;
border: 1px solid #ddd;
border-radius: 4px;
width: 100%;
box-sizing: border-box;
}

.ov_snapshot_preview_container {
margin: 20px 0;
text-align: center;
}

.ov_snapshot_preview_image {
border: 1px solid #ccc;
max-width: 100%;
height: auto;
border-radius: 4px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.ov_button {
padding: 10px 15px;
font-size: 1em;
color: #fff;
background-color: #007bff;
border: none;
border-radius: 4px;
cursor: pointer;
text-align: center;
width: 100%;
box-sizing: border-box;
}

.ov_button:hover {
background-color: #0056b3;
}

.ov_left_container {
width: 40%;
padding: 20px;
}

.ov_right_container {
width: 60%;
padding: 20px;
display: flex;
flex-direction: column;
gap: 20px;
}

.ov_step1, .ov_step2 {
padding: 20px;
}

.ov_email_fields_container {
margin-bottom: 20px;
}

.ov_preview_container {
display: flex;
flex-direction: column;
gap: 10px;
}

.ov_preview1_container {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}

.ov_preview_row {
display: flex;
width: 100%;
gap: 10px;
}

.ov_preview2_container, .ov_preview3_container {
flex: 1;
height: 150px;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}

.ov_preview2_container,
.ov_preview3_container {
width: calc(50% - 5px);
}

.ov_preview_container img {
width: 100%;
height: 100%;
object-fit: contain;
border: 1px solid #ddd;
border-radius: 4px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.ov_next_button, .ov_submit_button {
text-align: center;
padding: 10px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}

.ov_next_button:hover, .ov_submit_button:hover {
background-color: #0056b3;
}

.ov_info_fields_container {
margin-bottom: 20px;
display: flex;
flex-direction: column;
gap: 15px;
}

.ov_email_fields_container {
margin-bottom: 20px;
display: flex;
flex-direction: column;
gap: 15px;
}

.ov_input_wrapper {
display: flex;
align-items: center;
margin-bottom: 10px;
}
50 changes: 48 additions & 2 deletions source/website/highlighttool.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class HighlightTool {
this.button = null;
this.eventsInitialized = null;
this.activeTouches = 0;

this.overlappingMeshes = new Map();
}

InitEvents() {
Expand Down Expand Up @@ -188,13 +188,44 @@ export class HighlightTool {
}
}


ApplyHighlight(intersection) {
let highlightMesh = this.GenerateHighlightMesh(intersection);

// Check for overlapping meshes
let overlappingMeshes = this.GetOverlappingMeshes(highlightMesh);

if (overlappingMeshes.length >= this.maxOverlappingMeshes) {
// Remove the oldest overlapping mesh
let oldestMesh = overlappingMeshes[0];
this.RemoveHighlight({ point: oldestMesh.position });
overlappingMeshes.shift();
}

// Add the new mesh
this.highlightMeshes.push(highlightMesh);
this.viewer.AddExtraObject(highlightMesh);

// Update overlapping meshes
overlappingMeshes.push(highlightMesh);
this.overlappingMeshes.set(highlightMesh.uuid, overlappingMeshes);

this.viewer.Render();
}

GetOverlappingMeshes(newMesh) {
let overlapping = [];
let newBoundingBox = new THREE.Box3().setFromObject(newMesh);

for (let mesh of this.highlightMeshes) {
let meshBoundingBox = new THREE.Box3().setFromObject(mesh);
if (newBoundingBox.intersectsBox(meshBoundingBox)) {
overlapping.push(mesh);
}
}

return overlapping;
}

RemoveHighlight(intersection) {
let meshesToRemove = this.highlightMeshes.filter((mesh) => {
return this.IsIntersectionWithinBoundingBox(intersection, mesh);
Expand All @@ -204,13 +235,28 @@ export class HighlightTool {
this.viewer.RemoveExtraObject(mesh);
this.highlightMeshes = this.highlightMeshes.filter((m) => m !== mesh);
this.DisposeHighlightMesh(mesh);

// Update overlapping meshes
this.overlappingMeshes.delete(mesh.uuid);
for (let [key, value] of this.overlappingMeshes) {
this.overlappingMeshes.set(key, value.filter(m => m !== mesh));
}
});

if (meshesToRemove.length > 0) {
this.viewer.Render();
}
}

SetMaxOverlappingMeshes(limit) {
if (typeof limit === 'number' && limit > 0) {
this.maxOverlappingMeshes = Math.floor(limit);
console.log(`Max overlapping meshes set to ${this.maxOverlappingMeshes}`);
} else {
console.error('Invalid overlap limit. Please provide a positive number.');
}
}

DisposeHighlightMesh(mesh) {
DisposeThreeObjects(mesh);
this.viewer.scene.remove (mesh);
Expand Down
14 changes: 13 additions & 1 deletion source/website/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SetEventHandler, HandleEvent } from './eventhandler.js';
import { PluginType, RegisterPlugin } from './pluginregistry.js';
import { ButtonDialog, ProgressDialog } from './dialog.js';
import { ShowMessageDialog } from './dialogs.js';
import { ImportSettings } from '../engine/import/importer.js';

import * as Engine from '../engine/main.js';
export { Engine };
Expand All @@ -22,6 +23,7 @@ import './css/navigator.css';
import './css/sidebar.css';
import './css/website.css';
import './css/embed.css';
import './css/sharingdialog.css';

export const UI = {
ButtonDialog,
Expand All @@ -47,7 +49,7 @@ export function RegisterToolbarPlugin (plugin)
}

export function StartWebsite (externalLibLocation)
{
{
window.addEventListener ('load', () => {
if (window.self !== window.top) {
let noEmbeddingDiv = AddDiv (document.body, 'noembed');
Expand Down Expand Up @@ -81,6 +83,16 @@ export function StartWebsite (externalLibLocation)
fileInput : document.getElementById ('open_file')
});
website.Load ();

if (!website.hashHandler.HasHash()) {
// Load the default FBX model
let defaultModelUrl = 'assets/models/Y_Bot.fbx';
let importSettings = new ImportSettings();
importSettings.defaultLineColor = website.settings.defaultLineColor;
importSettings.defaultColor = website.settings.defaultColor;
HandleEvent('model_load_started', 'default');
website.LoadModelFromUrlList([defaultModelUrl], importSettings);
}
});
}

Expand Down
Loading

0 comments on commit 0b2ea1e

Please sign in to comment.