Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
29de1006
Commit
29de1006
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
obj parser placeholder
parent
7d16daac
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/apps/canvas/index.ts
+12
-0
12 additions, 0 deletions
src/apps/canvas/index.ts
src/mol-io/reader/obj/parser.ts
+23
-0
23 additions, 0 deletions
src/mol-io/reader/obj/parser.ts
with
35 additions
and
0 deletions
src/apps/canvas/index.ts
+
12
−
0
View file @
29de1006
...
...
@@ -8,6 +8,7 @@ import './index.html'
import
Viewer
from
'
mol-view/viewer
'
;
import
CIF
,
{
CifBlock
}
from
'
mol-io/reader/cif
'
import
{
parse
as
parseObj
}
from
'
mol-io/reader/obj/parser
'
import
{
readUrlAs
}
from
'
mol-util/read
'
import
{
Model
,
Format
,
Structure
,
StructureSymmetry
}
from
'
mol-model/structure
'
;
import
{
CartoonRepresentation
}
from
'
mol-geo/representation/structure/representation/cartoon
'
;
...
...
@@ -48,6 +49,15 @@ viewer.input.move.subscribe(({x, y, inside, buttons}) => {
info
.
innerText
=
`
${
label
}
`
})
async
function
getObjFromUrl
(
url
:
string
)
{
const
data
=
await
readUrlAs
(
url
,
false
)
as
string
const
comp
=
parseObj
(
data
)
const
parsed
=
await
comp
.
run
()
if
(
parsed
.
isError
)
throw
parsed
return
parsed
.
result
}
async
function
getCifFromUrl
(
url
:
string
)
{
const
data
=
await
readUrlAs
(
url
,
false
)
const
comp
=
CIF
.
parse
(
data
)
...
...
@@ -108,6 +118,8 @@ async function init() {
const
mesh
=
meshBuilder
.
getMesh
()
// Mesh.computeNormalsImmediate(mesh)
// mesh = getObjFromUrl('mesh.obj')
// add representation from custom mesh
const
customRepr
=
CustomRepresentation
()
await
customRepr
.
create
(
mesh
,
{
...
...
This diff is collapsed.
Click to expand it.
src/mol-io/reader/obj/parser.ts
0 → 100644
+
23
−
0
View file @
29de1006
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import
Result
from
'
../result
'
import
{
Task
,
RuntimeContext
}
from
'
mol-task
'
import
{
Mesh
}
from
'
mol-geo/shape/mesh
'
;
async
function
parseInternal
(
data
:
string
,
ctx
:
RuntimeContext
):
Promise
<
Result
<
Mesh
>>
{
// TODO
const
result
:
Mesh
=
Mesh
.
createEmpty
();
return
Result
.
success
(
result
);
}
export
function
parse
(
data
:
string
)
{
return
Task
.
create
<
Result
<
Mesh
>>
(
'
Parse OBJ
'
,
async
ctx
=>
{
return
await
parseInternal
(
data
,
ctx
);
});
}
export
default
parse
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment