Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
744402e
first commit, able to manually set object parameters and set world me…
Mar 5, 2020
5a36a3c
Added MapMetadataSettable, MapLocation, and NoteInfo classes to creat…
Mar 5, 2020
7b2aba8
Changes to type in a note into an arbitrary text field, click on a po…
Mar 11, 2020
1fe10ab
Only allow a note to be created if raycast point exists (the mesh has…
Mar 12, 2020
b066196
UI changes to indicate once a note is saved and once the entire set o…
Mar 12, 2020
04a60e2
Created a "Load" button to display cubes at each of the note location…
Mar 12, 2020
9670eac
Raycast against cubes in the scene, change cube color when raycast hi…
Mar 12, 2020
8d5ef4e
able to select a note, delete it, and the item will be removed from t…
Mar 16, 2020
8b10cb2
Added "edit-save" button to save edited text, which updates the note …
Mar 17, 2020
abc6f92
Remove the "edit" , "delete", and "edit-save" buttons when a raycast …
Mar 17, 2020
f9197e1
Load a mesh with notes, create a new note and save. Now the orginal n…
Mar 17, 2020
8e6a30b
Load a mesh with note, create a new note, save, and then load notes a…
Mar 18, 2020
1b2449a
Fixed issue when loading, then saving a new note, and then loading an…
Mar 18, 2020
8c897a7
Select a note, delete it, and make sure the cube is removed from the …
Mar 19, 2020
3568edf
Load a mesh with notes, edit a node, click away from it, edit again. …
Mar 20, 2020
be37c68
fixed spelling error
Mar 23, 2020
0f3a2ef
fixed hit test issue where cubes would attach to world origin
Mar 24, 2020
555b63f
corrected fix for hit test issue where cubes would attach to world or…
Mar 24, 2020
5dc2606
Merge branch 'mesh-notes-changes' of https://github.com/Placenote/spa…
Mar 24, 2020
c8ebb79
removes Edit, Delete, and Edit-Save buttons when a note is deleted
Mar 24, 2020
fb004bb
Remove load all notes button and load all notes by default
Mar 25, 2020
913ae34
Push metadata for every save, removed "Save All Notes" button, remove…
Mar 25, 2020
daebc1f
Merge branch 'mesh-notes-changes' of https://github.com/Placenote/spa…
Mar 25, 2020
84bd500
Fixed how userData was being set for each noteCube, so now a user can…
Mar 26, 2020
f196aea
Added dat.gui library to display noteText panel when raycast hits a n…
Mar 26, 2020
207753c
on text enter in dat.gui interface, the metadata is saved and the fir…
Mar 26, 2020
5e537a3
Added sweetalert2 to project, removed old Edit Button and replaced it…
Mar 27, 2020
a2dd03e
changed sweetalert cancel button text
Mar 27, 2020
a302cb2
Removed text input bar and save button, and created sweet alert input…
Mar 27, 2020
f94fc3d
changed sweetalert title for new note creation
Mar 27, 2020
a896bb8
Added delete note functionality to "Edit Note" popup, which is only t…
Mar 27, 2020
4b3a6d2
Fixed showLoading popup when setting metadata through creation, editi…
Mar 27, 2020
76b6060
Added CSS2DObject as labels using CSS2DRenderer. Labels are generated…
Mar 31, 2020
c8f2222
Removes cube from scene if canceling creation, and does not create cu…
Apr 1, 2020
79aaa04
Note text labels are now loaded when the mesh is loaded
Apr 1, 2020
1c0a53c
Added a bool value to setMeshMetadata function to display a different…
Apr 1, 2020
90bfbd1
Removes note labels from a scene when a note is deleted
Apr 1, 2020
4b9c1b6
Updates note labels once a note is edited and saved.
Apr 2, 2020
bf1ba86
Removed uneccessary object key for each note JSON object.
Apr 2, 2020
3b74120
Simplified deletion process by renaming note cube and note label prop…
Apr 3, 2020
4f8675d
On “view mesh” if there are existing notes, renders the notes after t…
Apr 3, 2020
3b2b65d
Replaces cube markers with note marker pins.
Apr 6, 2020
94c3808
Added rotation for each note marker
Apr 6, 2020
765059f
Removes note markers and labels based on note position, id, and text …
Apr 7, 2020
6640b92
Fix for note creation error
Apr 7, 2020
ca5dbc9
Additional comments and changed how place name is set
Apr 8, 2020
a68f6e2
Moved code to mesh-manager.js and referenced new build file name in s…
Apr 9, 2020
3100897
Set rotation of camera about center of mesh, disabled translation, an…
Apr 9, 2020
b9e0e7b
Update README.md file
Apr 9, 2020
374d564
Created separate function for calculating center point
Apr 9, 2020
c07e9f8
Created a button to scroll through notes and have camera focus on the…
Apr 13, 2020
b1f145f
Added Next and Previous button to switch between notes
Apr 14, 2020
54e35de
Note navigation uses NotesArray instead of labels array
Apr 14, 2020
3f77d17
Fixed logic issue with note navigation buttons
Apr 14, 2020
8f9ba6f
Added a "recalibrate" button to recentre the camera to the centre of …
Apr 17, 2020
bdd4bf8
Camera now moves closer to notes during note navigation, and is also …
Apr 17, 2020
ca393c2
Labels are now added children to note marker object instead of as sep…
Apr 20, 2020
b249f4b
Added a button to display all notes and position camera to the select…
Apr 21, 2020
b75fca9
Added toggle for top-down view and added button hover text. Also adde…
Apr 23, 2020
90b3585
Added a toggleLabelView button to choose when note labels appear in t…
Apr 27, 2020
e808fda
UI change to toggle icons for top-down viewing and label viewing
Apr 28, 2020
afabddf
Added option to create and add room markers and labels. Additional mi…
Apr 30, 2020
fab8cd7
Moved ApiKey, MapId, View Mesh, and Download Mesh panel to a separate…
Apr 30, 2020
62b3c5c
Changed logic so that all NoteInfo and RoomInfo classes have a unique…
Apr 30, 2020
453e3dd
Added image input for room creation, changed nav bar to use room imag…
May 4, 2020
f8bdb63
Added labels on hover for footer room image grid
May 4, 2020
8e3c84d
Added image to footer image row on room creation, and added horizonta…
May 5, 2020
3f19a72
Fixed camera movement for room and note navigation in top-down view.
May 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 247 additions & 4 deletions Lib/mesh-manager.js/build/mesh-manager.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,118 @@ var MeshManager = (function (exports, JSZip, JSZipUtils, threeFull) {
this.readyForRaycast = true;
this.lastRaycastPoint;
this.logging = false;
this.meshMetadata = null;
this.NotesArray = [];
}
/**
* @desc HELPER METHOD: Retrieves mesh metadata.
* Makes Http request to get metadata
*/
PlacenoteMesh.prototype._getMeshMetadata = function () {
const Http = new XMLHttpRequest();
const url = 'https://us-central1-placenote-sdk.cloudfunctions.net/getMetadata';
var apiKeyVal = document.getElementById('apikey').value;
var mapIdVal = document.getElementById('mapid').value;
Http.open("GET", url, true);
Http.setRequestHeader('APIKEY', apiKeyVal);
Http.setRequestHeader('placeid', mapIdVal);
Http.send();
Http.onreadystatechange = (e) => {
const jsonRes = JSON.parse(Http.response);
this.meshMetadata = jsonRes;
if (jsonRes.metadata.userdata.notesList) {
this.NotesArray = jsonRes.metadata.userdata.notesList;
}
this.NotesArray.forEach((noteObj) => {
// For some reason, _init() is being called twice, so this will prevent duplicate scene children
if (scene.getObjectByName(noteObj.noteText)) {
return;
}
if (scene.getObjectByName("Label: " + noteObj.noteText)) {
return;
}
// Loads note markers and note labels into the scene
var mtlLoader = new Three.MTLLoader();
mtlLoader.load( 'Lib/mesh-manager.js/marker-pin-obj/Pin.mtl', function( materials ) {
materials.preload();
var loader = new Three.OBJLoader();
loader.setMaterials( materials )
// This function is called on successful load
function callbackOnLoad ( obj ) {
obj.children[0].material = new Three.MeshBasicMaterial( {color: 0x1e90ff} ); // Sets object material to blue (temporary solution to Pin.mtl issue)
obj.scale.set(0.01,0.01,0.01); // Scales the object size down to fit the mesh
obj.className = "noteMarker";
obj.name = noteObj.noteText;
obj.userData = noteObj;
obj.position.set(noteObj.px,noteObj.py,noteObj.pz);
scene.add( obj );
markers.push(obj); // Adds to markers array defined in index.js
}
loader.load('Lib/mesh-manager.js/marker-pin-obj/marker.obj', callbackOnLoad, null, null, null );
});
var text = document.createElement( 'div' );
text.className = 'noteText';
text.textContent = noteObj.noteText;

var label = new Three.CSS2DObject( text );
label.name = "Label: " + noteObj.noteText;
label.position.set(noteObj.px,noteObj.py - 0.5,noteObj.pz);
scene.add( label );
});
return this.meshMetadata;
}
};

/**
* @desc HELPER METHOD: Sets mesh metadata.
* Makes Http request to set metadata
*/
PlacenoteMesh.prototype._setMeshMetadata = function (data, deleteNote) {
const Http = new XMLHttpRequest();
const url = 'https://us-central1-placenote-sdk.cloudfunctions.net/setMetadata';
var apiKeyVal = document.getElementById('apikey').value;
var mapIdVal = document.getElementById('mapid').value;
Http.open("POST", url, true);
Http.setRequestHeader('APIKEY', apiKeyVal);
Http.setRequestHeader('placeid', mapIdVal);

Http.send(JSON.stringify(data));
Swal.fire({
title: 'Saving Changes...',
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false,
onOpen: () => {
Swal.showLoading();
}
})
Http.onreadystatechange = (e) => {
if (Http.readyState == 4 && Http.status == 200) {
this.meshMetadata = data;
if (deleteNote) {
Swal.fire({
icon: 'success',
text: 'Note has been deleted!',
});
}
else {
Swal.close();
}
}
if (Http.status == 400) {
Swal.fire({
icon: 'error',
text: "'Oops...', 'Something went wrong!', 'error'",
});
}
}
}
/**
* @desc HELPER METHOD: initializes mesh for clickety click.
* Makes Http request to download dataset.json
* Calls _createClicketyClickCameras()
* @param onError (Optional) Error callback that receives the error as an argument
*/


PlacenoteMesh.prototype._init = function (onError) {
if (this.logging) console.log('Starting Initialization');
var scope = this;
Expand Down Expand Up @@ -200,7 +303,147 @@ var MeshManager = (function (exports, JSZip, JSZipUtils, threeFull) {
var scope = this;

for (var i = 0; i < intersects.length; i++) {
if (scope.readyForRaycast && intersects[i].object.name == 'PlacenoteMesh') {
// Checks if raycast hits either the mesh or an existing note marker
if (scope.readyForRaycast && (intersects[i].object.name == 'PlacenoteMesh' || intersects[i].object.parent.className == 'noteMarker')) {
var noteObj = intersects[i].object;
delete this.meshMetadata.metadata.created; // Removes parameter so valid metadata is passed
let meshMetadata = this.meshMetadata;

// Logic if raycast hits an existing object
if (intersects[i].object.parent.className == 'noteMarker') {
// Changes color of object when clicked on
intersects[i].object.material = new Three.MeshBasicMaterial( {color: 0xFFFF00} );
// Modal to enter note text
Swal.fire({
title: 'Edit Note!',
text: 'Enter note text here:',
input: 'text',
showCancelButton: true,
cancelButtonText: "Delete note",
confirmButtonText: "Save note info",
inputValue: noteObj.parent.userData.noteText, // Edit existing note text for that object
allowOutsideClick: false,
inputValidator: (noteText) => {
if(!noteText){
return 'You need to enter text!';
}
if( noteText.length > 100 ){
return 'You have exceeded 100 characters';
}
}
}).then(function(noteText) {
// Logic for delete button on edit popup
if (noteText.dismiss == "cancel") {
// Modifies notes list by removing the note being deleted from the array
scope.NotesArray.forEach((note) => {
// Compares note text and position values, which prevents deletion errors when multiple notes have the same note text
if (note.noteText == noteObj.parent.userData.noteText && note.px == noteObj.parent.position.x && note.py == noteObj.parent.position.y && note.pz == noteObj.parent.position.z) {
let index = meshMetadata.metadata.userdata.notesList.indexOf(note);
meshMetadata.metadata.userdata.notesList.splice(index, 1);
meshMetadata.metadata.userdata.notesList = scope.NotesArray;
scope._setMeshMetadata(meshMetadata, true);
}
})
// Removes note cube and note label from the scene
scene.remove(scene.getObjectById(noteObj.parent.id));

// This loop is necessary for removing correct label if there are multiple labels with the same text by comparing position values
scene.children.forEach((child) => {
if (child.name == "Label: " + noteObj.parent.userData.noteText && child.position.x == noteObj.parent.position.x && child.position.y == noteObj.parent.position.y - 0.5 && child.position.z == noteObj.parent.position.z) {
scene.remove(child);
}
});
}
// Logic for saving edited note information
else {
scope.NotesArray.forEach((note) => {
if (note.noteText == noteObj.parent.userData.noteText) {
// Removes note label from scene
scene.children.forEach((child) => {
if (child.name == "Label: " + noteObj.parent.userData.noteText && child.position.x == noteObj.parent.position.x && child.position.y == noteObj.parent.position.y - 0.5 && child.position.z == noteObj.parent.position.z) {
scene.remove(child);
}
});
note.noteText = noteText.value;
noteObj.parent.userData.noteText = noteText.value;
noteObj.parent.name = noteText.value;
}
})
// Update local array and call setMetadata endpoint
meshMetadata.metadata.userdata.notesList = scope.NotesArray;
scope._setMeshMetadata(meshMetadata, false);

// Create a new label for the note
var text = document.createElement( 'div' );
text.className = 'noteText';
text.textContent = noteText.value;

var label = new Three.CSS2DObject( text );
label.name = "Label: " + noteText.value;
label.position.set(noteObj.parent.userData.px, noteObj.parent.userData.py - 0.5, noteObj.parent.userData.pz);
scene.add( label );
}
});
}
// Logic if raycast hits the mesh
if (intersects[i].object.name == 'PlacenoteMesh') {
// Modal to enter note text
Swal.fire({
title: 'Create a Note!',
text: 'Enter note text here:',
input: 'text',
showCancelButton: true,
cancelButtonText: "Cancel",
confirmButtonText: "Save note info",
allowOutsideClick: false,
inputValidator: (noteText) => {
if(!noteText){
return 'You need to enter text!';
}
if( noteText.length > 100 ){
return 'You have exceeded 100 characters';
}
},
preConfirm: function(noteText) {
var point = scope.getRaycastPoint();
var noteInfo = new NoteInfo(point.x, point.y, point.z, noteText); // Class defined in index.js
const location = new MapLocation(0,0,0); // Class defined in index.js

scope.NotesArray.push(noteInfo);
let notesList = {notesList: scope.NotesArray};
let data = new MapMetadataSettable(meshMetadata.metadata.name, location, notesList); // Class defined in index.js
scope._setMeshMetadata({metadata: data}, false);

// Add cube at raycast point
var mtlLoader = new Three.MTLLoader();
mtlLoader.load( 'Lib/mesh-manager.js/marker-pin-obj/Pin.mtl', function( materials ) {
materials.preload();
var loader = new Three.OBJLoader();
loader.setMaterials( materials )
// This function is called on successful load
function callbackOnLoad ( obj ) {
obj.scale.set(0.01,0.01,0.01);
obj.className = "noteMarker";
obj.children[0].material = new Three.MeshBasicMaterial( {color: 0x1e90ff} );
obj.name = noteText;
obj.userData = noteInfo;
obj.position.set(point.x, point.y, point.z);
scene.add( obj );
markers.push(obj);
}
loader.load('Lib/mesh-manager.js/marker-pin-obj/marker.obj', callbackOnLoad, null, null, null );
});
var text = document.createElement( 'div' );
text.className = 'noteText';
text.textContent = noteText;

var label = new Three.CSS2DObject( text );
label.name = "Label: " + noteText;
label.position.set(point.x, point.y - 0.5, point.z);
scene.add( label );
}
});
}
// Take first intersection with mesh
if (scope.logging) console.log('Raycast to mesh is true');
scope.readyForRaycast = false;
Expand All @@ -217,7 +460,6 @@ var MeshManager = (function (exports, JSZip, JSZipUtils, threeFull) {
* @return THREE.Vector3 of raycast intersection point
*/


PlacenoteMesh.prototype.getRaycastPoint = function () {
if (this.lastRaycastPoint) return this.lastRaycastPoint;
return new threeFull.Vector3(1, 1, 1);
Expand Down Expand Up @@ -419,6 +661,7 @@ var MeshManager = (function (exports, JSZip, JSZipUtils, threeFull) {
mesh.name = 'PlacenoteMesh';
if (scope.logging) console.log('Loading mesh complete');
onLoad(mesh);
scope._getMeshMetadata();
};

var objLoader = new threeFull.OBJLoader2();
Expand Down
96 changes: 96 additions & 0 deletions Lib/mesh-manager.js/marker-pin-obj/Pin.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Pin
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _EMISSION
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MKGlowTex:
m_Texture: {fileID: 2800000, guid: d2bfdb919488ef040b6f7e30c6d08ebf, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _textureCbCr:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _textureY:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 0.78
- _Glossiness: 0.5
- _GlossyReflections: 1
- _InvFade: 1
- _MKGlowOffSet: 0
- _MKGlowPower: 0
- _MKGlowTexStrength: 3.857143
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _RimPower: 1.625
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _MKGlowColor: {r: 0.20392159, g: 0.5254902, b: 0.87843144, a: 1}
- _MKGlowTexColor: {r: 0.20392159, g: 0.5254902, b: 0.87843144, a: 1}
- _RimColor: {r: 0.13235295, g: 1, b: 1, a: 1}
Loading